In my demo project's build event, (a class library project), to copy the build result .dll
to a specific folder, (auto-created if it doesn't exist), I added following command line in Post-build event
command line section:
xcopy /Y "$(TargetDir)$(TargetFileName)" "$(SolutionDir)DemoApp\bin\$(ConfigurationName)\Packages\"
It works perfectly.
Then I tried to replace that command line with a call to a new batch file called CopyPackage.bat located in $(SolutionDir). The content of the batch file is exactly the command line above:
call $(SolutionDir)CopyPackage.bat
Then I rebuild the project and get following error:
Severity Code Description Project File Line Suppression State Error The command "call C:\TestProjects\DemoApp\CopyPackage.bat" exited with code 4. DemoApp
Do I miss something?
The solution after getting some hints from you all:
In post-build event command line I put: (see the params)
$(SolutionDir)CopyPackage.bat "$(TargetDir)$(TargetFileName)" "$(SolutionDir)DemoApp\bin\$(ConfigurationName)\Packages\"
In batch file CopyPackage.bat :
set targetfile=%~1
set targetdir=%~2
echo %targetfile%
echo %targetdir%
xcopy /Y %targetfile% %targetdir%