Make each csproj in solution target another version of C #

I have a solution containing five C # console application projects. I would like each project to target a different version of C #.

MyLearningSolution.sln CSharp01.csproj CSharp02.csproj CSharp03.csproj CSharp04.csproj CSharp05.csproj 

Is there a way to do this, either through Visual Studio or by editing each csproj ?

I tried the following searches:

  • The target version of C # for a specific version of C # , this means targeting a specific version of the framework

  • csproj select c # version does not answer the question

+5
source share
2 answers

This can be done by looking at the <LangVersion> element of the csproj file. Possible values:

 <LangVersion>default</LangVersion> <LangVersion>ISO-1</LangVersion> <LangVersion>ISO-2</LangVersion> <LangVersion>3</LangVersion> <LangVersion>4</LangVersion> <LangVersion>5</LangVersion> 

To do this using the user interface, go to Project Properties => Build => Advanced ... => Language Version

+10
source

Right-click on the project, go to the "Rulers" section, under Build click the Advanced.. button, there you can specify the language version.

enter image description here

+5
source

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


All Articles