title: Manage Microsoft and StyleCop code analysis rules at solution level
body: <p>I'm trying to bring code analysis to our projects, so I started with a solution with both .NET Framework and .NET Standard projects.</p>
  
  <p>I followed <a href="https://blog.submain.com/stylecop-detailed-guide/" rel="noreferrer">this tutorial</a> but to sum-up, here is what I did:</p>
  
  <ul>
  <li>Added a <code>SolutionName.ruleset</code> file at the solution level</li>
  <li>Added a <code>stylecop.json</code> file at solution level and referenced this file as link in each project</li>
  <li>Installed <code>StyleCop.Analyzers 1.1.0-beta009</code> Nuget package on every project</li>
  <li>Installed <code>Microsoft.NetCore.Analyzers</code> on .NET Standard projects and <code>Microsoft.NetFramework.Analyzers</code> for .NET Framework projects</li>
  </ul>
  
  <p>First of all, Visual Studio looks so buggy but it's maybe due to some black magic I don't understand.</p>
  
  <p>If I click on the ruleset file in the solution explorer, I play a bit with ticking and de-ticking the several checkboxes of each rules group and re-build to see the changes in the Error List window but after a short time it doesn't work anymore. I'm even trying to deselect everything, build again and all my warnings are still here. The only way to make them disappear is to close Visual Studio.</p>
  
  <p>As shown on the screenshot, I expended the .NET Standard library project called <code>ConfigLibrary</code> to see that it has several associated Analyzers.</p>
  
  <p><a href="https://i.stack.imgur.com/sKYor.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sKYor.png" alt="enter image description here"></a></p>
  
  <p>The problem is that all these rules seem to come from the Nuget package's DLL <code>C:\Users\user\.nuget\packages\stylecop.analyzers\1.1.0-beta009\analyzers\dotnet\cs\StyleCop.Analyzers.dll</code>.</p>
  
  <p>If I deselect the <code>StyleCop.Analyzers</code> rules in my ruleset file, it does nothing, and if I search for these rules codes using the search textbox, it shows they are not selected. But at the end these rules are still applied...</p>
  
  <p>When I try to uninstall the <code>StyleCop.Analyzers</code> Nuget package for all projects, then I don't get at all these warnings even when the rules are selected in my ruleset file.</p>
  
  <p>Also my ruleset file is often automatically re-written by I don't know what process. And the rules don't work anymore even after I restart Visual Studio</p>
  
  <p><a href="https://i.stack.imgur.com/5lYgQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5lYgQ.png" alt="enter image description here"></a></p>
  
  <p>So what is the proper way to handle some code analysis rule at the solution level for both .NET Framework and .NET Core projects? </p>
  
  <p>How to avoid the analyzers' DLLs to override my rules defined in my ruleset file? Is there a workaround to make Visual Studio properly refresh the applied rules? <code>Build</code>, <code>Rebuild</code> and <code>Run code analysis on solution</code> are all buggy, only restarting Visual Studio works but it's kind of a heavy workaround especially with all these rules...</p>
  
  <p>Is it me not understanding a basis concept or am I facing some weird bugs with .NET Core? Thank you</p>