【问题标题】:Visual Studio - Post-build eventVisual Studio - 生成后事件
【发布时间】: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


    【解决方案1】:

    系统错误码123的意思

    文件名、目录名或卷标语法不正确。

    如果您使用的是 Windows,请使用反斜杠 \ 而不是正斜杠 / 作为目录分隔符,并首先从命令行尝试该命令。您可能还需要使用绝对路径或 Visual Studio 项目路径变量,因为 VS 的运行时当前目录(在它运行构建后命令时)可能与您的预期不同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多