Back in the good old days, when the Windows start menu wasn’t designed for smartphones, the free Windows SDK 7.1 shipped with all .NET 4.0 compilers and even Visual C++. As noted previously, Microsoft decided to stop this generosity and removed all compilers from the new Windows SDK 8.0 for .NET 4.5. In the case of Visual C++ that’s it – you definitely need Visual Studio 2012 to get the new compiler.
However, I just realized that the standard .NET Framework runtime actually contains MSBuild and compilers for C#, Visual Basic, JScript, and MSIL! So these tools are already available on every Windows 8 system, or any other .NET 4.5 installation. The .NET reference assemblies and some other tools are missing, such as ILDASM and the assembly linker, but those items are included in the free Windows SDK 8.0.
So it’s still possible to set up a complete .NET 4.5 development environment for the command line, without Visual Studio 2012 but with the original Microsoft compilers and libraries rather than Mono’s. Here’s what you need to do:
Add the .NET 4.5 directory for your Windows bitness to your
PATH. On my 64-bit system, that’s
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319". On a 32-bit system, simply remove the
64. The path uses the old .NET 4.0 version number because 4.5 deploys as an in-place upgrade to 4.0. Try running
csc.exeto verify the actual version.
Download the Windows SDK 8.0 installer. Run it and select “.NET Framework 4.5 Software Development Kit” for installation. You can deselect everything else, though you may want to examine the available options. The SDK’s reference assemblies are registered automatically for use by the compilers.
Add the directory with the SDK’s .NET utilities to your path. That’s
"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools"in a default installation. On a 64-bit system, you should first add the same path followed by
\x64, for those tools that have 64-bit versions. (You might not need the 32-bit directory at all in this case, but I’m not sure about that.)
And that’s it!
csc.exe should now compile your typical “Hello, World” program just fine. MSBuild could also build some old projects I had created in Visual Studio 2010, although with some version warnings because the projects targeted .NET 4.0 and the SDK 8.0 reference assemblies are for 4.5. If that’s a concern you could always install the SDK 7.1 to get the original .NET 4.0 reference assemblies.
Just as with the old SDK 7.1, this is a bare-bones setup. You’ll have to write your build files by hand, and you won’t have an IDE with debugger and IntelliSense. Still, the old-fashioned command-line approach is perfectly workable for getting a taste of C# and for writing small tests and utilities.