Robocopy outputs 1 upon success, unlike most programs that exit with 0 on success. Visual Studio (and MSBUILD) interprets exit code of 1 as an error.
How can Robocopy b
Simply checking for an exit code of 1 is incorrect, as any exit code below 8 is non-erroneous:
Any value greater than 8 indicates that there was at least one failure during the copy operation.
(Just to clarify, an exit code of 8 is an error as well: Several files did not copy
)
The proper code, then, should look like this:
IF %ERRORLEVEL% GEQ 8 exit 1
exit 0