What are the specific version numbers of the C# 4,

2019-09-20 23:57发布

I know that I've got the C# 6 compiler and I use C# 6 features often and when I write applications to practice, I usually target .NET v4.6.

On this machine, I have Visual Studio 2010, 2013, 2015 and 2017 installed.

When I type csc.exe from the .NET Framework v4 directory, it shows me the compiler version as 4.6.1098.0 for C# 5, which is very confusing.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>csc Microsoft (R) Visual C# Compiler version 4.6.1098.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. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

And when I type the same command on another laptop of mine where I have only Visual Studio 2013 installed, I get the following output from the csc.exe command.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>csc 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. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

Observe that it reads 4.6.1055.0 for C# 5.

  1. So, my first question is: what are the different version numbers of the C# compilers for C# 4, 5 and 6?

  2. Second, how do I know which version of the csc.exe file, and thus which version of the C# compiler, my Visual Studio installation is using to compile my files? To try this on my own, I created a console application on each of my two machines and chased down the project files. They both had an MS Build Import directive for the Microsoft.Csharp.targets file from the MS Build bin folder. But I gave up reading from inside that file because I still don't fully understand all of the MS Build tags.

1条回答
smile是对你的礼貌
2楼-- · 2019-09-21 00:25

what are the different version numbers of the C# compilers for C# 4, 5 and 6?

As the latest C# versions here, Visual Studio 2010 and Visual Studio 2013 are use the C# 4 & 5 compiler, and just as Cody Gray said, the compilers are backwards-compatible, meaning that the C# 5 compiler can target an older version of C#. So they are both C# 5. Besides, starting with Visual Studio 2013, MSBuild and the C# compilers are now available as a standalone package,Microsoft® Build Tools. This package is installed with Visual Studio 2013. Then you can get the version number of the C# 6 from the path: C:\Program Files (x86)\Microsoft Visual Studio 14.0

how do I know which version of the csc.exe file, and thus which version of the C# compiler, my Visual Studio installation is using to compile my files?

The csc.exe file in MSBuild folder is internal used by MSBuild. You can get the C# compiler version from the path: C:\Program Files (x86)\Microsoft Visual Studio 14.0\csc.exe

enter image description here

查看更多
登录 后发表回答