Analyzers are sort of a mess right now IMHO. If you read this article at MS then it tells you which packages to use but those packages are listed as deprecated. The runtime you are targeting is important here.
The main analyzer package seems to be Microsoft.CodeAnalysis.NETAnalyzers
. If you are targeting .NET Framework in your project then you need to add a reference to the nuget package. If you are targeting .NET 5 then it is included automatically. If you are targeting .NET Core/Standard then set the EnableNETAnalyzers
property to true. In my experience you also need to add the nuget package right now. All this is somewhat documented here. If you get a build warning then remove the project property.
Note that analyzer rules change over time so refer to this doc for what is currently available. Some are disabled and would need to be turned on. Not all the FxCop rules are converted. Some are no longer best practices or applicable while others have not been converted. You could include the deprecated FxCop package if you wanted but it might conflict with the new analyzers.