如何从团队构建的msbuild批处理文件中调用msbuild?

时间:2011-12-16 02:54:03

标签: msbuild team-build

我正在使用Team Build(2010)调用带有Exec任务的msbuild脚本,该任务调用批处理文件,该批处理文件又调用msbuild。像这样:

<Exec Command="BatchFileThatCallsMSBuild.bat" />

当然批处理文件还有很多其他垃圾,或者我只是使用MSBuild任务。

问题是,当批处理文件试图调用msbuild时,它无法找到它。

'msbuild' is not recognized as an internal or external command, operable program or batch file.

如何在exec任务中设置必要的环境?

我尝试将命令更改为:

<Exec Command="%22$(VS100COMNTOOLS)..\..\VC\vcvarsall.bat%22&amp;BatchFileThatCallsMSBuild.bat" />

但没有骰子,仍未找到msbuild。

1 个答案:

答案 0 :(得分:2)

我想出的答案是利用很少演示的在线多行命令字符串来执行Exec任务。

<Exec Command="call &quot;%VS100COMNTOOLS%..\..\VC\vcvarsall.bat&quot; x86
    set AnotherEnvVar=$(RandomMSBuildProperty)
    call BatchFileThatCallsMSBuild.bat
    type file_with_output_from_the_msbuilds_in_the_batchfile.log" />

这让我设置基本构建环境(调用vcvarsall),将msbuild属性推送到Exec的环境,批处理的msbuild可以看到它,调用批处理文件,甚至将隐藏的msbuild输出拉到在Team Build中更清晰的日志记录的Exec任务级别。

我不喜欢在我的代码中嵌入对这个特定VS版本的另一个引用,但它现在可以工作。