I have a project with a post build event:
copy $(ProjectDir)DbVerse\\Lunaverse.DbVerse.*.exe $(TargetDir)
It works fine every time on my m
I have added this for future visitors since this is quite an active question.
ROBOCOPY exits with "success codes" which are under 8. See: http://support.microsoft.com/kb/954404
This means that:
robocopy exit code 0 = no files copied
robocopy exit code 1 = files copied
When the result is 1, this becomes an error exit code in visual studio.
So i solved this easily by adding this to the bottom of the batch file
exit 0
Suggest that handle ROBOCOPY errors in this fashion
rem each robocopy statement and then underneath have the error check.
if %ERRORLEVEL% GEQ 8 goto failed
rem end of batch file
GOTO success
:failed
rem do not pause as it will pause msbuild.
exit 1
:success
exit 0
Confusion will set in when no files are copied = no error in VS. Then when there are changes, files do get copied, VS errors but everything the developer wanted was done.
Additional Tip: Do not use a pause in the script as this would become an indefinite pause in the VS build. while developing the script, use something like timeout 10
. You will notice this and comment it out rather than have a hanging build.