Search code examples
c#visual-studiovisual-studio-2017

How to change C# Language Version for all of the projects in my solution in one place?


I have a solution with 20 projects, I want to change the C# version for all of them to C# 7.3

Is there a way that I could change all project's version at one go? I know I can change the Language Version from Project's Properties, but I don't want to repeat this 20 times.

enter image description here


Solution

  • To set a version for all your project at once, you can create a file named Directory.Build.props (case-sensitive on Linux) at the root of your repository. This file contains the list of common properties of your projects:

    <Project>
      <PropertyGroup>
        <LangVersion>latest</LangVersion>
        <!--<LangVersion>preview</LangVersion>-->
        <!--<LangVersion>7.3</LangVersion>-->
      </PropertyGroup>
    </Project>
    

    https://www.meziantou.net/4-ways-to-enable-the-latest-csharp-features.htm#method-4-using-a-pro