Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between Visual Studio (.sln) build runner and MSBuild

Tags:

I'm trying to set TeamCity to do a CI using .Net and configuring build runners I have:

  1. Visual Studio (sln)
  2. MSBuild
  3. Visual Studio 2003

What's the difference? Why three build to work on the same type of project? (With the exception of 2003 which is only for 2003 I believe, Why?)

Taking the issue, we have this build runners for .exe files:

  1. .NET Process Runner
  2. Command Line

The "Command Line" build runner not works with any .net assembly? Why the .Net Process Runner?

like image 925
Acaz Souza Avatar asked Feb 14 '12 12:02

Acaz Souza


People also ask

What is the difference between MSBuild and Visual Studio build?

Visual Studio determines the build order and calls into MSBuild separately (as needed), all completely under Visual Studio's control. Another difference arises when MSBuild is invoked with a solution file, MSBuild parses the solution file, creates a standard XML input file, evaluates it, and executes it as a project.

Can I use MSBuild without Visual Studio?

To install MSBuild on a system that doesn't have Visual Studio, go to Build Tools for Visual Studio 2022 on the downloads page. Another way of getting MSBuild is to install the . NET SDK.

How does MSBuild create solution?

To build a specific target of a specific project in a solution. At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute.


2 Answers

Visual Studio (sln)
If your solution is small and you are not required to do fancy things you can use Visual Studio (sln) build runner. It does exactly the same thing as when you do Project->Build (from VS menu). This option is very easy to configure, a few clicks and your CI server compiles your solution.

MSBuild
If you need to do more advanced scenarios, apart from simple compilation, like apply different config files, insert transformed values into config file, deploy binaries etc, you would select MSBuild option. You will know when you need to use this, simply because sln builder will not be capable of doing stuff. This option requires some knowledge of build scripting language, which is a task-based and xml-like.

like image 190
oleksii Avatar answered Sep 27 '22 21:09

oleksii


When you use MSBuild to build a .SLN file ( non MSBuild document ) it generates an in memory MSBuild file that references all of the projects to build in the specified configuration and then executes it. When you use Visual Studio to build you are calling DevEnv.com instead.

There are certain project types ( C++ in 2005/2008 and VDPROJ in 2005/2008/2010 ) that aren't MSBuild files and can't be build using just MSBuild. You will get a build warning saying that one or more projects were not valid MSBuild projects and could not be built.

In geneneral I try to maintain lean and mean build machines and only install Visual Studio if needed.

like image 43
Christopher Painter Avatar answered Sep 27 '22 20:09

Christopher Painter