How do I write a build batch script that runs vcvars32.bat, and then continues with the build?

冷暖自知 提交于 2019-12-03 22:51:51

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:

@echo off
call "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
vcbuild

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

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.

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 2005    VS80COMNTOOLS
Visual Studio 2008    VS90COMNTOOLS
Visual Studio 2010    VS100COMNTOOLS
Visual Studio 2012    VS110COMNTOOLS
Visual Studio 2013    VS120COMNTOOLS

You get the idea.

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