【发布时间】:2021-05-03 14:53:32
【问题描述】:
我有一个在 Visual Studio 中编译的 C# 库。当该项目成功编译时,我想创建一个 .zip 文件。但是,我需要使用自定义编码。出于这个原因,我需要使用 .NET CreateFromDirectory 方法。我的问题是,如何在 Visual Studio 的构建后事件中使用 .NET 方法?目前,我有以下内容:
Add-Type -Assembly 'System.IO.Compression.ZipFile'
[System.IO.Compression.ZipFile]::CreateFromDirectory(".", "../$(SolutionName).zip")
当我运行它时,我收到一条错误消息:
Error MSB3073 The command "Add-Type -Assembly 'System.IO.Compression.ZipFile'
[System.IO.Compression.ZipFile]::CreateFromDirectory(".", "../MySolution.zip")
" exited with code 123. MySolution C:\Repositories\MySolution\MyProject.csproj 56
我做错了什么?如何从 Visual Studio 中的构建后事件运行 .NET 方法?
【问题讨论】:
标签: c# powershell