From 2fabc0f9d3aae1c42cdc4db19f912d5fce61d450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Wed, 18 Oct 2023 06:05:35 +0200 Subject: [PATCH] New instructions about nested Directory.Build.props usage --- Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md b/Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md index 7da36459..88f00069 100644 --- a/Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md +++ b/Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md @@ -21,6 +21,18 @@ This will completely disable code analysis packages. To also disable .NET SDK an dotnet_analyzer_diagnostic.category-Style.severity = none ``` +Note that MSBuild only loads in the closest _Directory.Build.props_ file to the project being built. So if you also used a _Directory.Build.props_ file to enable _Lombiq.Analyzers_ in a higher directory, it is now overridden. This can be a problem if you rely on `Lombiq.Analyzers` to set up compiler properties such as ``. Put this into the _Directory.Build.props_ file instead: + +```xml + + + false + + + + +``` + ## How to disable all analyzers during `dotnet build` By default the `dotnet build` command runs analyzers and produces code analysis warnings if there are any but it makes the build slower. Pass the `/p:RunCodeAnalysis=false` parameter to disable analyzers during build, like: