TreatWarningsAsErrors
The build property that turns every compiler and analyzer warning into an error, so code with warnings fails to build.
In more detail
It stops warnings accumulating unnoticed and makes the quality bar part of the build contract. Set it once in Directory.Build.props.
Example
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>Related terms
- compiler warning — A message from the compiler or an analyzer about code that builds but is probably wrong, identified by a code such as CS8602.
- Roslyn analyzer — A plug-in to the C# compiler that inspects code while you edit and build, and reports diagnostics about likely bugs, unsafe patterns or style.
- Directory.Build.props — An MSBuild file placed in a folder that every project in that folder and below imports automatically, used for shared build settings.
Taught in
- Directory.Build.props, global.json and Central Packages — Modern .NET Core, C# & Enterprise Microservices
- Code Quality: .editorconfig and Roslyn Analyzers — Modern .NET Core, C# & Enterprise Microservices