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

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

    Syntactically here is a one-line-per-command version that works directly within the PreBuild steps:

    (robocopy "$(ProjectDir)..\Dir1" "$(ProjectDir)Dir1" "Match.*" /a+:R) ^& IF %ERRORLEVEL% GEQ 8 exit 1
    (robocopy "$(ProjectDir)..\Dir2" "$(ProjectDir)Dir2" "Match.*" /a+:R) ^& IF %ERRORLEVEL% GEQ 8 exit 1
    exit 0
    

    References:

    • @OhadSchneider answer for GEQ 8
    • This answer on why exit 0 needs to be at the end.

提交回复
热议问题