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.
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.
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.
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.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With