我使用的是Visual Studio 2017,我想添加一個後期構建命令。當我進入'宏'窗口時,我看到正確的路徑coresponging爲$(ProjectDir)變量。所以我加了命令:
$(ProjectDir)ClientApp\npm run build
但是當我執行編譯我收到以下錯誤:
The command 'ClientApp\npm run build'exited with code 3.
更改MSBuild的詳細診斷並在輸出窗口,我看到:
1>Target "PostBuildEvent" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets": 1> Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". 1> Task "Exec" 1> Task Parameter:WorkingDirectory=bin\Debug\netcoreapp1.1\ 1> Task Parameter:Command=ClientApp\npm run build 1> ClientApp\npm run build 1> The system cannot find the path specified. 1>
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4933,5): error MSB3073: The command "ClientApp\npm run build" exited with code 3. 1> Done executing task "Exec" -- FAILED.
在目標文件中我得到了這些行:
<Target
Name="PostBuildEvent"
Condition="'$(PostBuildEvent)' != '' and ('$(RunPostBuildEvent)' != 'OnOutputUpdated' or '$(_AssemblyTimestampBeforeCompile)' != '$(_AssemblyTimestampAfterCompile)')"
DependsOnTargets="$(PostBuildEventDependsOn)">
<Exec WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" />
</Target>
我可以將工作目錄從$(OutDir)更改爲$(ProjectDir)以及如何?
任何想法我錯了嗎? NB - 我在一個BAT文件添加的命令,只是爲了測試,但結果是一樣的
謝謝你這對我的作品^^ –
問題是,爲什麼$(PROJECTDIR ) 是空的? – MistyK