C# 用于命令行构建的 MSBuild 与 devenv

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9604511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 08:06:33  来源:igfitidea点击:

MSBuild vs devenv for command line builds

c#c++visual-studio-2010msbuilddevenv

提问by Filip Fr?cz

I was wondering: what is the difference between using msbuild and devenv when compiling solutions from the command line?

我想知道:从命令行编译解决方案时使用 msbuild 和 devenv 有什么区别?

One obvious thing noticed was that msbuild does build dependent projects not contained within the solution, while devenv does not.

注意到的一件明显的事情是 msbuild 确实构建了未包含在解决方案中的依赖项目,而 devenv 则没有。

Are there any other? Are there some special flags one could pass to msbuild to make it match the devenv build exactly?

还有其他的吗?是否有一些特殊的标志可以传递给 msbuild 以使其与 devenv 构建完全匹配?

P.S. I'm using Visual Studio 2010 SP1

PS 我使用的是 Visual Studio 2010 SP1

采纳答案by Christian.K

According to this MSDN Blog Entrythey try to minimize the differences, but those that exist (i.e. using an integrated C# compiler instead of csc.exeor setting the BuildingInsideVisualStudioproperty) are mainly done to optimize the performance of builds.

根据这个MSDN 博客条目,他们试图最小化差异,但那些存在的差异(即使用集成的 C# 编译器代替csc.exe或设置BuildingInsideVisualStudio属性)主要是为了优化构建的性能。

回答by Alberto De Caro

I have experienced a project within a multilayer team: developers, testers, deployers. MSBuild was the main tool of the deployers: they could compile and recompile, just setting building parameters editing the xml config file of MSBuild without opening the devenv. In fact, they often used MSBuild in pre-prod environment where there was not devenv at all.

我在多层团队中经历过一个项目:开发人员、测试人员、部署人员。MSBuild 是部署者的主要工具:他们可以编译和重新编译,只需设置构建参数,编辑 MSBuild 的 xml 配置文件,无需打开 devenv。事实上,他们经常在没有 devenv 的预生产环境中使用 MSBuild。

Nant is a similar tool by Apache Foundation.

Nant 是 Apache 基金会的一个类似工具。

For further info have a look here:

有关更多信息,请查看此处:

回答by shamp00

The main advantage of MSBuild is that you don't need to have Visual Studio installed.

MSBuild 的主要优点是您不需要安装 Visual Studio。

One limitation of MSBuild is that it does not support building Visual Studio setup projects (.vdproj).

MSBuild 的一个限制是它不支持构建 Visual Studio 安装项目 ( .vdproj)。

(You can work around this by defining an exec task which calls devenv, but then you still need Visual Studio.)

(您可以通过定义一个调用 devenv 的 exec 任务来解决这个问题,但是您仍然需要 Visual Studio。)

回答by RunHolt

Another major difference is that msbuildhas some options that don't exist for devenv. As far as I can tell, there is no way to increase verbosity for devenvbut you can increase the verbosity for msbuildby the option:

另一个主要区别是它msbuild有一些不存在的选项devenv。据我所知,无法增加详细程度,devenv但您可以msbuild通过以下选项增加详细程度:

/v:diag

回答by Alan

I encountered a case where devenvwrote an error message when a project file was missing, but returned 0 anyway. By contrast, msbuildreturned a nonzero value. I switched our makefile over to using msbuildso we wouldn't overlook errors.

我遇到过这样一种情况,devenv即在项目文件丢失时写了一条错误消息,但无论如何都返回 0。相比之下,msbuild返回一个非零值。我将我们的 makefile 切换为 using,msbuild这样我们就不会忽略错误。