windows 如何编写运行 vcvars32.bat 的构建批处理脚本,然后继续构建?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/762539/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I write a build batch script that runs vcvars32.bat, and then continues with the build?
提问by Jared Oberhaus
I want to write a simple batch script that loads the Visual Studio build environment using vcvars32.bat
and then continue with the build, using vcbuild
. However, my script won't execute past the invocation of vcvars32.bat
. The last output I get is:
我想编写一个简单的批处理脚本来加载 Visual Studio 构建环境vcvars32.bat
,然后使用vcbuild
. 但是,我的脚本不会在调用vcvars32.bat
. 我得到的最后输出是:
Setting environment for using Microsoft Visual Studio 2008 x86 tools.
As you can see I'm using Visual Studio 2008. Here is my simplest batch script:
如您所见,我使用的是 Visual Studio 2008。这是我最简单的批处理脚本:
@echo off
"C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
vcbuild
回答by Jared Oberhaus
You have to use call
in your batch script, or the termination of vcvars32.bat
will terminate your own batch script. Therefore your script should be:
您必须call
在您的批处理脚本中使用,否则终止vcvars32.bat
将终止您自己的批处理脚本。因此你的脚本应该是:
@echo off
call "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
vcbuild
回答by Paul Alexander
You'll also want to check that the script hasn't run already or you'll start running out of memory if you invoke your script over and over in the same console.
您还需要检查脚本是否尚未运行,否则如果您在同一个控制台中一遍又一遍地调用脚本,您将开始耗尽内存。
IF '%VSINSTALLDIR%' NOT EQU '' THEN EXIT 0
回答by Jim Balkwill
The exact program files path depends on whether you have a 32 or 64 bit OS and where you installed Visual Studio. Use the VS100COMNTOOLS environment variable which Visual Studio sets up at install time to solve this problem generically.
确切的程序文件路径取决于您使用的是 32 位还是 64 位操作系统以及您安装 Visual Studio 的位置。使用 Visual Studio 在安装时设置的 VS100COMNTOOLS 环境变量一般可以解决此问题。
call "%VS100COMNTOOLS%\..\..\VC\bin\vcvars32.bat"
...
Note that each version of Visual Studio has a specific environment variable based on its underlying version number.
请注意,每个版本的 Visual Studio 都有一个基于其底层版本号的特定环境变量。
Visual Studio 2005 VS80COMNTOOLS
Visual Studio 2008 VS90COMNTOOLS
Visual Studio 2010 VS100COMNTOOLS
Visual Studio 2012 VS110COMNTOOLS
Visual Studio 2013 VS120COMNTOOLS
You get the idea.
你明白了。