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
With
robocopy
set rce=%errorlevel%
if not %rce%==1 exit %rce% else exit 0
For instance, if we want to copy the project target to c:\temp, without retries and with all sub-directories (empty or not), we'd use:
robocopy /R:0 /E $(TargetDir) c:\temp
set rce=%errorlevel%
if not %rce%==1 exit %rce% else exit 0