Search code examples
c#visual-studio-2012msbuildwarnings

Suppress warning on solution level. Treat warning as error on solution level


I am trying to set global rules for my team. We are using VS2012 with TFS for our C# projects. I'd like to suppress some of the warnings and also treat some of the warnings as errors. I found the way to do it on the project level - project properties -> build tab.

But we have solution with more than hundred projects and I am looking for some easier way to set those rules globally.


Solution

  • As of MSBuild 15 (circa 2017) you can use Directory.Build.Props file in the top folder of your solution. The syntax is the same as csproj, fsproj, or vbproj file and the entries are treated as though they are injected into all project files. You will need to restart Visual Studio to apply the changes. (thanks Jumbo!)

    <Project>
      <PropertyGroup>
        <WarningsAsErrors>CS4014, CS1998</WarningsAsErrors>
      </PropertyGroup>
    </Project>