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

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

    I found that it's much easier to start robocopy rather than trying to call it in-line with Visual Studio. This way Visual Studio doesn't care about the return code from robocopy.

    start robocopy . ..\latestbuild
    

    The only difference I could see is that you will see a command prompt appear and disappear to execute the robocopy command.

    Using call instead of start actually doesn't open the command prompt and, even better, redirects the output from the robocopy to Visual Studio output window.

    call robocopy . ..\latestbuild
    

    For some reason this approach only works when used in Pre-build events command line.

提交回复
热议问题