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

前端 未结 7 2056
忘了有多久
忘了有多久 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:33

    With , being the copy source and target respectfully, and being robocopy options:

    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
    

提交回复
热议问题