简体   繁体   中英

failed pre-build event in visual studio 2010 cancels build

I have a python script which runs and generates a version-file. I use the following as a pre-build event for my project:

call python version.py

this works fine given that I have python installed and the file can be found. However, for users that don't, it throws an error and cancels the build.

Is there a way to make it so the visual studio just silently ignores the build event if the python-command is not found or the python-file is not found?

One option would be to wrap the call to python in a .bat file which will exit with 0 if python is not found, and replace the pre-build step with calling this .bat file.

An example of such a test could be:

python --version >nul
if errorlevel 1 exit 0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM