Proj0025: Migrate from ruleset file to .globalconfig file
Microsoft deprecated the use of .ruleset
in favor of .globalconfig
files.
In Visual Studio by clicking the file, it will automatically pop up a dialog to
convert the ruleset.
Alternatively, you can download the converter yourself from NuGet. For more info: learn.microsoft.com
Note the difference between .editorconfig
and .globalconfig
here. It is
advised to put analyzer configuration in the [.globalconfig
file](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/configuration-files#global-analyzerconfig).
Non-compliant
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<CodeAnalysisRuleSet>MyPreferences.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
</Project>
Compliant
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
</Project>
.globalconfig
is_global = true
dotnet_diagnostic.CA1000.severity = warning
...
or with an explicit import of a config file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup Label="Analyzer configuration">
<GlobalAnalyzerConfigFiles Include="analyzers-config.ini" />
</ItemGroup>
</Project>