Docs: Document <LangVersion> for csproj files

Created on 2 Aug 2017  路  4Comments  路  Source: dotnet/docs

The C# build system now includes a node inside a csproj file that controls which version of C# the compiler should follow. Valid values include:

  • ISO-1
  • ISO-2
  • C# 3.0
  • C# 4.0
  • C# 5.0
  • C# 6.0
  • C# 7.0
  • C# 7.1 (beginning with .NET Core 2.0)
  • latest (latest minor version)
  • default (latest major version)

This can be set using the Visual Studio IDE, or editing the CSProj file.

@mairaw Can this be done with a dotnet CLI command?

Area - .NET Core Guide Area - C# Guide P1

Most helpful comment

One issue is to point out that you should select "all configurations", not just "debug" (which is the default).
This is a common pitfall, from the feedback so far.
So it would be great if we could include that in future instructions.

All 4 comments

@BillWagner Also please document:

Visual Studio has an option for language version with "C# latest major version (default)". Which I assume means "7.0" rather than "7.1" which is confusing because most advice in SO/blogs is to do nothing and get the latest and greatest automatically though msbuild defaults.

But actually, to get 7.1 I need to do <LangVersion>latest</LangVersion>.

Might be done as part of #2642. The new topic for 7.1 already mentions this.

Also re. your question:

Can this be done with a dotnet CLI command?

I haven't seen that. Adding @livarcocc and @nguerrera to help with that.

One issue is to point out that you should select "all configurations", not just "debug" (which is the default).
This is a common pitfall, from the feedback so far.
So it would be great if we could include that in future instructions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tswett picture tswett  路  3Comments

garfbradaz picture garfbradaz  路  3Comments

JagathPrasad picture JagathPrasad  路  3Comments

skylerberg picture skylerberg  路  3Comments

Manoj-Prabhakaran picture Manoj-Prabhakaran  路  3Comments