Reputation: 2435
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.
Upvotes: 31
Views: 11943
Reputation: 2868
If you're from Linux world(like me), you can try to understand it in this way: MSBuild
is like Make
, which a build system (although MSBuild is a more modern one, but the core functionality is the same). And csc.exe
is like gcc
is compiler.
For a hello world tiny project, just use compiler directly is acceptable. But if you're working on a very large project consists of hundreds or thousands of source file, you will need a build system to control the process.
Upvotes: 0
Reputation: 12683
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
Upvotes: 41
Reputation: 5305
MSBuild
in fact uses csc.exe
, so you can use both in command line. MSBuild
is a bit easier to use.
Command-line Building with csc.exe
Upvotes: 6
Reputation:
In C#
your code first compile to IL
code and then JIT
compiler compile your code to CPU Instructions .So all compiler should compile your code to IL
.
So what is msBuild:
The Microsoft Build Engine (MSBuild) is the new build platform for Microsoft and Visual Studio. MSBuild is completely transparent with regards to how it processes and builds software, enabling developers to orchestrate and build products in build lab environments where Visual Studio is not installed
See:
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.
Upvotes: 0