Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild vs devenv for command line builds

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

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

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

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

like image 276
Filip Frącz Avatar asked Mar 07 '12 15:03

Filip Frącz


People also ask

What is the difference between MSBuild and Devenv?

Devenv uses MSBuild to build projects, but MSBuild does not build Visual C++ Projects. If MSBuild comes across a solution that includes Visual C++ projects, it will call VCBuild. If the projects are using C++, then MSBuild is not called.

How use MSBuild command line?

To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.

What does Devenv setup do?

Devenv lets you set various options for the IDE, build projects, debug projects, and deploy projects from the command line. Use these switches to run the IDE from a script or a . bat file (such as a nightly build script), or to start the IDE in a particular configuration.


5 Answers

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

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

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

like image 138
shamp00 Avatar answered Oct 06 '22 05:10

shamp00


According to this MSDN Blog Entry they try to minimize the differences, but those that exist (i.e. using an integrated C# compiler instead of csc.exe or setting the BuildingInsideVisualStudio property) are mainly done to optimize the performance of builds.

like image 26
Christian.K Avatar answered Oct 06 '22 05:10

Christian.K


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.

Nant is a similar tool by Apache Foundation.

For further info have a look here:

  • MSBuild
  • Nant
like image 38
Alberto De Caro Avatar answered Oct 06 '22 05:10

Alberto De Caro


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

/v:diag
like image 38
RunHolt Avatar answered Oct 06 '22 05:10

RunHolt


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

like image 34
Alan Avatar answered Oct 06 '22 06:10

Alan