Is Microsoft.CodeAnalysis.CSharp.CodeStyle still needed for a .NET 6 project?

Viewed 19

I need to migrate a .NET Core 3.1 C# project to .NET 6. The .NET Core 3.1 project uses the analyzers Microsoft.CodeAnalysis.NetAnalyzers and Microsoft.CodeAnalysis.CSharp.CodeStyle as NuGet packages.

For Microsoft.CodeAnalysis.NetAnalyzers Microsoft clearly states that it is not needed as a NuGet package anymore. https://github.com/dotnet/roslyn-analyzers#microsoftcodeanalysisnetanalyzers:

You do not need to manually install this NuGet package [Microsoft.CodeAnalysis.NetAnalyzers] to your project if you are using .NET5 SDK or later. These analyzers are enabled by default for projects targeting .NET5 or later.

What's not so clear to me is whether the Microsoft.CodeAnalysis.CSharp.CodeStyle NuGet package can also be abandoned. Some things I read and manual tests suggest that adding <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> to the project file is sufficient. However, I found no specific confirmation for this.

Can someone confirm or correct and ideally shed some light on the relationship between Microsoft.CodeAnalysis.CSharp.CodeStyle and <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>?

0 Answers
Related