I am trying to compile a C# project that someone has created while using C# 6.0 features.
In previous .NET releases, the current C# compiler was automatically installed and ready to run along with the .NET Framework. Apparently, this is no longer the case. I currently have .NET 4.6.1 on my machine, but invoking csc
tells me:
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.
This compiler is provided as part of the Microsoft (R) .NET Framework, but only
supports language versions up to C# 5, which is no longer the latest version. Fo
r compilers that support newer versions of the C# programming language, see http
://go.microsoft.com/fwlink/?LinkID=533240
The link forwards me to the Roslyn project on Github. It does not seem to offer any binary releases.
Curiously, googling for C# 6.0 compiler
brings up a couple of discussions on how to add C# 6.0 support to Visual Studio 2013 (with the consensus being more or less that you can't), and countless articles presenting the (admittedly wonderful) new features of C# 6.0, but not a hint on how to obtain a compiler for C# 6.0.
So: How can I get the MS C# 6.0 compiler, and, if required, the necessary build tools such as current versions of MSBuild?
Note that I do not usually have Visual Studio installed, as SharpDevelop seems to be superior for my purposes, so I am wary of installing several gigabytes of data when I already have the framework just to get the up-to-date compiler.
From the Roslyn project on GitHub:
To install the latest release without Visual Studio, run one of the following nuget command lines:
nuget install Microsoft.Net.Compilers # Install C# and VB compilers nuget install Microsoft.CodeAnalysis # Install Language APIs and Services
To get the latest "preview" drop, published about once per month, add the
-pre
switch to the nuget commands.
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