Visual Studio $(ProjectDir)为空字符串

时间:2017-04-18 07:55:12

标签: c# .net visual-studio msbuild post-build-event

我正在使用Visual Studio 2017,我想添加一个post-build命令。当我进入'宏'窗口时,我看到正确的路径核心为$(ProjectDir)变量。所以我添加了命令:

  

$(ProjectDir)ClientApp \ npm run build

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

  

命令'ClientApp \ npm run build'与代码3一起使用。

我将MSBuild verbose更改为Diagnose,并在Output窗口中看到:

  

1>在文件“C:\ Program Files(x86)\ Microsoft”中定位“PostBuildEvent”   视觉   工作室\ 2017年\社区\的MSBuild \ 15.0 \斌\ Microsoft.Common.CurrentVersion.targets“:   1 GT;使用程序集“Microsoft.Build.Tasks.Core”中的“Exec”任务,   Version = 15.1.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a“。   1 GT;任务“Exec”1>任务   参数:WorkingDirectory = bin \ Debug \ netcoreapp1.1 \ 1>任务   参数:Command = ClientApp \ npm run build 1> ClientApp \ npm运行   构建1>该系统找不到指定的路径。 1 GT;
  C:\ Program Files(x86)\ Microsoft Visual   工作室\ 2017年\社区\的MSBuild \ 15.0 \斌\ Microsoft.Common.CurrentVersion.targets(4933,5):   错误MSB3073:命令“ClientApp \ npm run build”退出并带有代码   3. 1>完成执行任务“Exec” - FAILED。

在目标文件中,我得到了以下这些内容:

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

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

  </Target>

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

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

1 个答案:

答案 0 :(得分:8)

尝试$(MSBuildProjectDirectory)

相关问题