How to determine C # compiler version on command line

Is there any command to get the C # compiler version? csc command seams csc not have the ability to display the compiler version.

PS when I enter the csc command in the Developer Command Prompt for VS2015 , it returns:

 Microsoft (R) Visual C# Compiler version 1.3.1.60616 Copyright (C) Microsoft Corporation. All rights reserved. 

However, I am sure my C # compiler is newer than 1.3!

+5
source share
2 answers

Keep in mind that your computer will have at least 2 versions of csc.exe. One of them comes as part of the .NET Framework installation, as always, and follows the version numbering of the framework. Saved in c: \ windows \ microsoft.net \ framework \ v4.0.30319, it is saved there for compatibility with System.CodeDom and sgen.exe. Frozen in C # version 5. Most programmers will now have version 4.7.x.0 if they have .NET v4.7 on their computer.

The other was allocated as part of the Roslyn project and is stored in the MSBuild directory. With the version number reset, which will start numbering again from 1. You will start it when using the Developer Command command line. The most likely reason for the reset version number is their desire not to fall within the scope of the release cadence, Roslyn suffered from a very large number of bugs requiring fixes for intermediate releases. A notable issue caused by decoupling was the addition of a new ValueTuple type in C # v7, required due to the significantly improved tuple support. A compiler sent before the structure was available, and programmers had to return to using the Nuget package for a while.

Resetting the version number occurs infrequently. But another good example that everyone knows about is .NETCore, it got a reset from 5.0 to 1.0. I have never seen a solid excuse for this, other than "avoiding confusion," I think it was a step to make it fresh.

+4
source

As a literal answer to the question new-ish [ update: roslyn versions above 2, see comment from Cameron MacFarland ], csc versions have a version / version switch

 c:\>csc /version 2.3.2.62116 (8522b473) 

For scripting (if you want to include a version), testing %errorlevel% of csc /version might be enough to put in an too old bucket.

/version , however, DOES NOT appear in https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/listed-alphabetically (which seems to be the newest version), and I can not find what or in the list on which version was added.

UPDATE: I would also be very careful with the version number reported by csc, for example, my personal 'default' is in C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn and has version 2.3.2.62116 (and file date 22/9/2017), but I also have C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe with version 4.7.2046.0 (and file date 18/03 / 2017) (and which does not accept the / version switch).

So, in response to

Is there any command to get the C # compiler version?

I would say yes, perhaps sometimes, but I would consider this version with a pinch of salt. Looking at the version stamps, I have a version representing the FIle version of the csc.exe assembly, which seems to come out of the โ€œlarger entityโ€ version that compiled csc, and there are at least incompatible numbering schemes for Rosyln compilers and "Traditional."

+1
source

Source: https://habr.com/ru/post/1273841/


All Articles