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

I am trying to establish global rules for my team. We are using VS2012 with TFS for our C # projects. I would like to suppress some warnings and also treat some warnings as errors. I found a way to do this at the project level - project properties -> build tab.

But we have a solution with over a hundred projects, and I'm looking for an easier way to set these rules around the world.

+6
source share
1 answer

The solution is just a (rather dumb) container for projects. If you open it in a text editor, you will quickly see that it cannot be expanded, add only projects / elements.

What you want is one or more common msbuild files that define all the necessary parameters for the compiler / linker / any tools you use, and Import in each individual project. We have used this for many years and it’s very convenient (although part of the convenience, we probably also wrote a small tool for creating project files to automatically import global properties, so we don’t have to bother with them manually)

Alternatively, you can add the file with the machine, look in the file $ (MSBuildToolsPath) \ Microsoft.CSharp.targets to find out where to place these files. I am not going to copy / paste the contents here, but the very first lines basically check if there are user files with errors, for example $ (MSBuildExtensionsPath) \ $ (MSBuildToolsVersion) \ $ (MSBuildThisFile) \ ImportBefore, and if so, all imported before all common msbuild materials. Similarly, the end of Microsoft.CSharp.targets contains similar logic for importing files after all common msbuild files.

+5
source

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


All Articles