I am using Visual Studio 2017 and I want to add a post-build command. when I go to 'Macros' window I see the correct path coresponging to $(ProjectDir) variable. So I added the command:
$(ProjectDir)ClientApp\npm run build
but when I execute build I get the following error:
The command 'ClientApp\npm run build'exited with code 3.
I change MSBuild verbose to Diagnose and in the Output window I saw:
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.
In the targets file I got these lines:
<Target
Name="PostBuildEvent"
Condition="'$(PostBuildEvent)' != '' and ('$(RunPostBuildEvent)' != 'OnOutputUpdated' or '$(_AssemblyTimestampBeforeCompile)' != '$(_AssemblyTimestampAfterCompile)')"
DependsOnTargets="$(PostBuildEventDependsOn)">
<Exec WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" />
</Target>
Can I change the working dir from $(OutDir) to $(ProjectDir) and how?
Any ideas where I am mistaken? NB - I added the command in a BAT file, just to test but the result was the same