我正在使用 Visual Studio 2017,我想添加一个构建后命令。当我转到“宏”窗口时,我看到正确的路径与 $(ProjectDir) 变量对应。所以我添加了命令:



但是当我执行 build 时,我收到以下错误:



我将 MSBuild 详细更改为诊断,并在输出窗口中看到:



在目标文件中,我得到了以下几行:

  <Target
      Name="PostBuildEvent"
      Condition="'$(PostBuildEvent)' != '' and ('$(RunPostBuildEvent)' != 'OnOutputUpdated' or '$(_AssemblyTimestampBeforeCompile)' != '$(_AssemblyTimestampAfterCompile)')"
      DependsOnTargets="$(PostBuildEventDependsOn)">

    <Exec WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" />

  </Target>

我可以将工作目录从 $(OutDir) 更改为 $(ProjectDir) 吗?如何更改?

任何想法我错了?
注意 - 我在 BAT 文件中添加了命令,只是为了测试但结果是一样的

最佳答案

尝试 $(MSBuildProjectDirectory) 代替

关于c# - Visual Studio $(ProjectDir) 是空字符串,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43466667/

10-10 23:19