Make each csproj in a solution target a different C# version

时间秒杀一切 提交于 2019-12-19 19:14:04

问题


I have a solution that contains 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 via Visual Studio or via editing each csproj file?

I have tried the following searches:

  • csproj target specific C# version, this talks about targeting a specific framework version

  • csproj choose c# version, doesn't answer the question


回答1:


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 it via the UI, go to Project Properties => Build => Advanced... => Language Version




回答2:


Right click on Project, go to Properites, There under Build click the Advanced.. button, there you can specify Language version.



来源:https://stackoverflow.com/questions/28859651/make-each-csproj-in-a-solution-target-a-different-c-sharp-version

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!