Using robocopy with Visual Studio 2010 Post-build and Pre-build events

前端 未结 7 2062
忘了有多久
忘了有多久 2021-02-05 01:59

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

7条回答
  •  灰色年华
    2021-02-05 02:32

    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
    

提交回复
热议问题