0

I manually invoke the C# compiler using the command line in order to compile a C# source file. However, the compilation sticks to C# 5. I access it using the path to VS2017, so I expected it to work on higher versions of C# as well. Setting the /langversion property does not seem to do the trick.

Any help?

PS C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Roslyn> csc
Microsoft (R) Visual C# Compiler version 4.7.2558.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

warning CS2008: No source files specified error CS1562: Outputs without source must have the /out option specified

.. but only supports language versions up to C# 5

NineBerry
  • 26,306
  • 3
  • 62
  • 93
  • Hmm, you do seem to do this right, that directory has the latest version of csc.exe. Tell us about the file size and timestamp on that file and whether you used the Developer Command Prompt. "PS" is not quite encouraging. – Hans Passant Oct 04 '18 at 14:17

1 Answers1

3

Your Visual Studio installation or your Build Tools installation is out of date.

With the current version, which is 15.8.6, you should get the following output:

PS C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn> .\csc
Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354)
Copyright (C) Microsoft Corporation. All rights reserved.

warning CS2008: No source files specified.
error CS1562: Outputs without source must have the /out option specified
user247702
  • 23,641
  • 15
  • 110
  • 157