Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild vs compiler

What is the difference between using MSBuild and the C# compiler from a command prompt? I want to manually build my solutions/projects without using Visual Studio and I want to learn how to use the command line tools.

like image 357
HelloWorld Avatar asked Jan 10 '14 05:01

HelloWorld


People also ask

What is MSBuild used for?

The Microsoft Build Engine is a platform for building applications. This engine, which is also known as MSBuild, provides an XML schema for a project file that controls how the build platform processes and builds software.

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.

Is MSBuild part of .NET framework?

MSBuild 4.5 is still part of the . NET 4.5. 1 Framework. The Framework's MSBuild will still be used by Visual Studio 2012, and is able to build any projects that round trip from Visual Studio 2013 to Visual Studio 2012.


2 Answers

By C# compiler do you mean csc.exe?

If that is what you mean, then csc and MSBuild are completely different applications.

MSBuild uses a solution and project files to build the files in your project. MSBuild uses csc.exe as its actual compiler but knows where to find assemblies, references etc based on your solution and project files (these files are actually xml files).

When using csc.exe you must manually provide paths to your files, references and so on, thus making your compilation much more difficult.

MSDN MSBuild: http://msdn.microsoft.com/en-us/library/dd393574.aspx

MSDN CSC : http://msdn.microsoft.com/en-us/library/78f4aasd.aspx

like image 168
Nico Avatar answered Sep 22 '22 13:09

Nico


MSBuild in fact uses csc.exe, so you can use both in command line. MSBuild is a bit easier to use.

MSBuild Reference (MSDN)

Command-line Building with csc.exe

like image 39
Arin Ghazarian Avatar answered Sep 22 '22 13:09

Arin Ghazarian