Guys. I'm confused. I'm trying to have a mechanism like the settings.stylecop file where I can have all my exceptions to rules and apply it to all my projects.
I've spent enough time on the site trying to figure out how to do this. Can someone help out with this?
Thanks.
Hi @WiseArch,
The best way I can think of is to use a single ruleset file and use it in every project you want. There you can specify the severity of each diagnostic and you can disable them if you want.
What do you mean use a single rulesset file? Should I include the file in the rest of my projects as a linked item? Is that the best way, or can I just have a solution level stylecop.json, or stylecop.ruleset?
CA ruleset file... See #1
Yes, according to the docs (https://msdn.microsoft.com/en-us/library/dd465181.aspx) you can specify a solution level ruleset, but does StyleCop.Analyzers honor this?
Is there any way to provide a solution level stylecop.json?
+1
Solution level configuration (stylecop.json) would be convenient.
@veleek Visual Studio and Roslyn are responsible for applying the rule set(s). StyleCop Analyzers runs whatever rules it is instructed to run by the compiler, and does not attempt to enable/disable rules or change their severity for you. In other words, it might work and would be great if it did; if it fails you should report a Roslyn bug since it sounds like that is a simpler way to configure a rule set for multiple projects.
@sharwell Yeah, that's kind of what I meant. The rule sets are something that Visual Studio is responsible for managing, but stylecop.json is a uniquly StyleCop Analyzers thing. And since there's a method for providing a Solution level rules set, how can I provide a solution level stylecop.json?
This doesn't _seem_ resolved to me.
@veleek stylecop.json is used for configuring the behavior of enabled rules. It is not used for enabling/disabling rules. If you want to disable one or more rules, you will need to add a ruleset file to your code base, at which point you can reuse that ruleset across multiple projects in the solution.
No one said that stylecop.json is for enabling/disabling rules. The question was how to use a solution level configuration stylecop.json file. I found this while scanning this repo so putting the stylecop.json in the solution root and referencing it in every project like this should work:
<ItemGroup>
<AdditionalFiles Include="..\stylecop.json">
<Link>stylecop.json</Link>
</AdditionalFiles>
</ItemGroup>
This information should be in EnableConfiguration.md I guess.
@Dresel I was answering what I interpreted as the original question (see especially the title of the issue). Looking back at the documentation, it's clear that the part you are referring to is missing. My guess is it would be most appropriate in Configuration.md: Getting Started with stylecop.json, plus a brief expansion of EnableConfiguration.md: Next Steps to include the wording "and additional configuration scenarios".
Yes that would be very helpful for others.
@sharwell Totally agree. Just having a bit of extra documentation around this seems perfectly reasonable to me.
Apologies if this isn't the correct place to post.
With regard to enabling stylecop.json, the instructions currently mention unloading the project, editing the project file then reloading the project.
The same can be accomplished without un/reloading the project. By going to the property pane for stylecop.json, AdditionalFiles can be selected as the Build Action.

Hope this helps.
@StefanKowalewski You are completely right, but that feature isn't available until Update 3 of VS2015. I'll create a new issue to update the text in EnableConfiguration.md .
Thank you @vweijsters . Didn't realize it's only been available since Update 3.
Most helpful comment
+1
Solution level configuration (stylecop.json) would be convenient.