Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

c# 6.0 - How to install the MS C# 6.0 compiler?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...