2

我需要使用 devenv.exe 来构建我们的 VS2010 项目。我需要项目一次构建 1 个,因为同时运行多个构建会导致问题。我在工具 -> 选项 -> 项目和解决方案 -> 构建和运行中将并发构建的数量设置为 1。当我直接从 VS2010 执行构建时,一切正常。

------ Rebuild started: Project: project1, Configuration: Release Win32 ------
.
Compile Output
.
------ Rebuild started: Project: project2, Configuration: Release Win32 ------
.
Compile Output
.

但是当我从命令行运行它时

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" C:\Users\Me\project\MySolution.sln /rebuild "Release|win32" /project C:\Users\Me\project\MyProject.vcxproj /out C:\DevEnv.log

它开始并行构建项目。

Microsoft (R) Visual Studio Version 10.0.30319.1. 
Copyright (C) Microsoft Corp. All rights reserved.
1>------ Rebuild All started: Project: project1, Configuration: Release Win32 ------
2>------ Rebuild All started: Project: project2, Configuration: Release Win32 ------
3>------ Rebuild All started: Project: project3, Configuration: Release Win32 ------
4>------ Rebuild All started: Project: project4, Configuration: Release Win32 ------

在使用命令行时,我是否缺少一个标志或设置来让这些构建一次运行 1?

编辑:应该注意的是我在 Jenkins 中运行这个构建。在命令提示符下运行上述命令时,它似乎工作正常。但是在 Jenkins 中运行命令会导致构建并行执行。也许需要设置一些环境变量?

4

1 回答 1

0

我从未见过有人尝试使用 devenv.exe 从命令行构建解决方案。我认为那是因为 devenv.exeVisual Studio。您最好改用 MSBuild。VS 所做的任何事情 MSBuild 都应该能够做到,因为 VS 在后台使用 MSBuild。它应该能够在不修改的情况下构建您的解决方案和/或项目文件。

既然您说您使用 Jenkins 进行 CI,请查看此用于 Jenkins 的 MSBuild 插件。

https://wiki.jenkins-ci.org/display/JENKINS/MSBuild+Plugin

于 2014-02-14T19:27:25.227 回答