我有一个调用MSBuild
的批处理文件,并构建了三个Visual Studio解决方案:
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
MSBuild solution0.sln /property:Configuration=Release
MSBuild solution1.sln /property:Configuration=Release
MSBuild solution2.sln /property:Configuration=Release
这很好用。但是,我想提示用户选择要构建的程序版本。根据用户输入,我们构建了一组特定的解决方案。
我的问题是,如果我在调用PATH
后修改vcvarsall
变量,则无法再拨打MSBuild
。
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
set /P version="Enter the version number [1] or [2]:"
IF %version% == 1 (
set PATH="%PATH%;%PATH_TO_VERSION1_LIBS%"
MSBuild solution0_v1.sln /property:Configuration=Release
MSBuild solution1_v1.sln /property:Configuration=Release
MSBuild solution2_v1.sln /property:Configuration=Release
)
IF %version% == 2 (
set PATH="%PATH%;%PATH_TO_VERSION2_LIBS%"
MSBuild solution0_v2.sln /property:Configuration=Release
MSBuild solution1_v2.sln /property:Configuration=Release
MSBuild solution2_v2.sln /property:Configuration=Release
)
我收到以下错误:
Setting environment for using Microsoft Visual Studio 2010 x86 tools.
ERROR: Cannot determine the location of the VS Common Tools folder.
这很令人费解,因为定义了环境变量VS100COMNTOOLS
。
答案 0 :(得分:3)
这可能是解析错误,请尝试:
IF "%version%"=="1" set "PATH=%PATH%;%PATH_TO_VERSION1_LIBS%"
IF "%version%"=="1" (
MSBuild solution0_v1.sln /property:Configuration=Release
MSBuild solution1_v1.sln /property:Configuration=Release
MSBuild solution2_v1.sln /property:Configuration=Release
)
IF "%version%"=="2" set "PATH=%PATH%;%PATH_TO_VERSION2_LIBS%"
IF "%version%"=="2" (
MSBuild solution0_v2.sln /property:Configuration=Release
MSBuild solution1_v2.sln /property:Configuration=Release
MSBuild solution2_v2.sln /property:Configuration=Release
)