Is it possible to install a C# compiler without Visual Studio?

I want to build projects from the command line. Is it possible to deploy a C# compiler without installing Visual Studio?


Sure, the framework includes a compiler, csc.exe. Look at this article for a quick how-to. The important parts:

You can get the command-line compiler (csc.exe) from Microsoft site http://msdn2.microsoft.com/en-us/netframework/aa731542.aspx.

Download the redistributable package of the .NET Framework, which includes the compiler and the .NET Framework with C# 2005 syntax support.

The compiler is located in the following directory: %windir%\Microsoft.NET\Framework\

Also look at this MSDN article for a full guide and explanation.

Note that for more recent versions, you will be looking for the MSBuild standalone package rather than the framework -- see @Vadzim's answer.


Of course. Do:

sudo apt-get install mono-gmcs

Everyone else assumed Windows and MS .NET, but...


Yes, if you have the .NET SDK, it's there. For example,

C:\WINDOWS\Microsoft.NET\Framework\v[your version number]\csc.exe

msbuild.exe should be there too, and you can use that to build project (.csproj) files.