Post build event in VS2012..Running a Batch file

心不动则不痛 提交于 2019-12-04 09:48:01

You are getting a VS error because it returned an exit code that is not 0. This does not necessarily mean there was an error.

The error code returned means that no files were copied. These are the return codes for Xcopy:

  • Exit Code
    • 0 Files were copied without error.
    • 1 No files were found to copy.
    • 2 The user pressed Ctrl+C to terminate xcopy.
    • 4 Various errors including insufficient memory or disk space, an invalid drive name, or invalid syntax.
    • 5 Disk write error occurred.

Try this code in your batch file. Use the /Y so that you will not have to deal with any prompts. You can handle the return code of 1 with another action or just return 0.

VS Post Build command line code:

CALL "$(SolutionDir)"Deploy.bat "$(ProjectDir)bin" "$(SolutionDir)Deploy\bin"

Deploy.bat file

Xcopy %1 %2 /S /Y

If errorlevel 1 @exit 0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!