One suggestion is to write a custom MSBuild Task to ensure that StyleCop.Analyzers is referenced in the packages.config for all of the projects.
No automatic way that I know of, but...
1) Add a build task as suggested above
2) Create a custom project template setup the way you want it
3) Create a test case which checks that all your projects reference the analyzers you want
4) Write a script which adds missing references
+1
As I known, we can use the command shown below to run StyleCop classical without add config to new project:
msbuild /p:CustomAfterMicrosoftCSharpTargets="C:\Program Files (x86)\MSBuild\StyleCop\v4.7\StyleCop.Targets";SourceAnalysisOverrideSettingsFile="<CustomeSettingFilePath>" SomeProject.csproj
That's a harmless method to handle all project and enforce them follow a unified rule setting.
Can StyleCop Analyzer work like the StyleCop classic?
So if you have a large product (200+ projects), is the only way to use the new StyleCop is to include it as a NuGet reference in every project file?
@sixlettervariables You can include it via Directory.Build.props and have it apply to many projects in subdirectories. Here is an example from Microsoft/vs-threading:
Most helpful comment
@sixlettervariables You can include it via Directory.Build.props and have it apply to many projects in subdirectories. Here is an example from Microsoft/vs-threading:
https://github.com/Microsoft/vs-threading/blob/167b298f6b99296eea89dd528437ee06555dbfbe/src/Directory.Build.props#L12-L16