Visual Studio $(ProjectDir) 为空字符串
Visual Studio $(ProjectDir) is empty string
我正在使用 Visual Studio 2017,我想添加一个 post-build 命令。当我转到 'Macros' window 时,我看到正确的路径 coresponging 到 $(ProjectDir) 变量。所以我添加了命令:
$(ProjectDir)ClientApp\npm run build
但是当我执行构建时出现以下错误:
The command 'ClientApp\npm run build'exited with code 3.
我将 MSBuild 详细更改为诊断并在输出中 window 我看到:
1>Target "PostBuildEvent" in file "C:\Program Files (x86)\Microsoft
Visual
Studio17\Community\MSBuild.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
Studio17\Community\MSBuild.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) 吗?如何更改?
我有什么想法是错误的吗?
注意 - 我在 BAT 文件中添加了命令,只是为了测试,但结果是一样的
改用 $(MSBuildProjectDirectory)
该问题也可能影响其他 VS 变量。
通用解决方案描述为 here.
我正在使用 Visual Studio 2017,我想添加一个 post-build 命令。当我转到 'Macros' window 时,我看到正确的路径 coresponging 到 $(ProjectDir) 变量。所以我添加了命令:
$(ProjectDir)ClientApp\npm run build
但是当我执行构建时出现以下错误:
The command 'ClientApp\npm run build'exited with code 3.
我将 MSBuild 详细更改为诊断并在输出中 window 我看到:
1>Target "PostBuildEvent" in file "C:\Program Files (x86)\Microsoft Visual Studio17\Community\MSBuild.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 Studio17\Community\MSBuild.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) 吗?如何更改?
我有什么想法是错误的吗? 注意 - 我在 BAT 文件中添加了命令,只是为了测试,但结果是一样的
改用 $(MSBuildProjectDirectory)
该问题也可能影响其他 VS 变量。 通用解决方案描述为 here.