Skip to content

Commit

Permalink
New instructions about nested Directory.Build.props usage
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Oct 18, 2023
1 parent 67d6bce commit 2fabc0f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Lombiq.Analyzers/Docs/ConfiguringAnalyzers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<LangVersion>`. Put this into the _Directory.Build.props_ file instead:

```xml
<Project>
<PropertyGroup>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
</Project>
```

## 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:
Expand Down

0 comments on commit 2fabc0f

Please sign in to comment.