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 1/4] 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: From bab7603e693579283ec03054f66f7a2e3524d950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Thu, 19 Oct 2023 13:53:14 +0200 Subject: [PATCH 2/4] Docs formatting --- Lombiq.Analyzers/Docs/AddingAnalyzers.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lombiq.Analyzers/Docs/AddingAnalyzers.md b/Lombiq.Analyzers/Docs/AddingAnalyzers.md index 29368d7c..ce23e16b 100644 --- a/Lombiq.Analyzers/Docs/AddingAnalyzers.md +++ b/Lombiq.Analyzers/Docs/AddingAnalyzers.md @@ -17,9 +17,9 @@ You only need to reference a single project; e.g., even though Orchard Core apps If you don't want to stay on the cutting-edge version, nor do you intend to contribute to Lombiq .NET Analyzers, you can use one of the NuGet packages. Install the package suitable for your project, as described above. Check for the latest version number [on NuGet](https://www.nuget.org/packages/Lombiq.Analyzers/). ```csproj - - all - + + all + ``` The `all` is necessary to prevent the analyzers "leaking" into other projects that may consume yours. From 9973430f923a9fca34fd7ea813470ec5ccbc0184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Thu, 19 Oct 2023 15:49:57 +0200 Subject: [PATCH 3/4] Update documentation. --- Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md b/Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md index 30d47f2c..3ca9149e 100644 --- a/Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md +++ b/Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md @@ -8,19 +8,16 @@ Place a _Directory.Build.props_ file into the project's folder (or folder with s ```xml - - - ``` -This will completely disable code analysis packages. To also disable .NET SDK analysis override them from a _.globalconfig_ file placed into the given project's folder. There you can disable any unwanted rules, like disabling .NET code style analysis completely: +MSBuild only loads in the closest _Directory.Build.props_ file to the project being built. So this empty props file will supersede any parent _Directory.Build.props_. To also disable .NET SDK analysis override them from a _.globalconfig_ file placed into the given project's folder. There you can disable any unwanted rules, like disabling .NET code style analysis completely: ```editorconfig 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: +If you rely on `Lombiq.Analyzers` to set up compiler properties such as `` you may still want to import the parent _Directory.Build.props_ file and just disable the code analyzers. Put this into the _Directory.Build.props_ file instead: ```xml From 8778087deb4246a9823469d3be6c4b41a569ee27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Thu, 19 Oct 2023 18:03:48 +0200 Subject: [PATCH 4/4] Elaborating on using false --- Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md b/Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md index 3ca9149e..14382878 100644 --- a/Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md +++ b/Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md @@ -29,6 +29,8 @@ If you rely on `Lombiq.Analyzers` to set up compiler properties such as ` ``` +Or if you added `Lombiq.Analyzers` to only a single project as a package reference, you can just add the `false` element. + ## 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: