【发布时间】:2013-07-05 23:35:29
【问题描述】:
我有一个调用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
这很好用。但是,我想提示用户选择要构建的程序版本。根据用户输入,我们构建了一组特定的解决方案。
我的问题是,如果我在调用vcvarsall 之后修改PATH 变量,我将无法再调用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。
【问题讨论】:
-
去掉 PATH 赋值中的双引号。
-
@HansPassant 我添加了双引号,因为我使用的是 64 位机器。带有
C:\Program Files (x86)等特殊字符的目录会破坏批处理命令。 -
它不会破坏 PATH 环境变量,嵌入空格很好。这 ;分号使其明确。您尝试过还是只是假设它不起作用?
-
通过特殊字符,我指的是括号。在这里查看答案:stackoverflow.com/a/2771431/1538531
标签: visual-studio-2010 windows-7 batch-file msbuild