简体   繁体   English

Visual Studio 2010中失败的预构建事件取消了构建

[英]failed pre-build event in visual studio 2010 cancels build

I have a python script which runs and generates a version-file. 我有一个运行并生成版本文件的python脚本。 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. 鉴于我已经安装了python并且可以找到该文件,所以这个工作正常。 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? 有没有一种方法可以使Visual Studio在找不到python-command或python-file的情况下仅忽略生成事件?

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. 一种选择是将对python的调用包装在.bat文件中,如果未找到python,它将以0退出,并用调用此.bat文件替换预构建步骤。

An example of such a test could be: 此类测试的示例可能是:

python --version >nul
if errorlevel 1 exit 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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