How to Disable StyleCop for Certain Projects

StyleCop can be a great help to ensure that every developer in a project formats code the same way. However, what is great for production code may not be what you want for your little throw away experiments. Let’s look on our options to disable StyleCop when we don’t need it.

 

Change the default behaviour of StyleCop

By default, StyleCop activates the rules for every project. If you don’t want that for most of your projects, then you can turn it off in the global settings. Go to the installation folder of StyleCop and open the file Settings.Stylecop. Locate the GlobalSettings section and add this line to disable the default rule checking:

I use the StyleCop plugin of ReSharper and don’t have a standalone installation of StyleCop. The global Settings.Stylecop is in my case in the AppData folder (C:\Users\***\AppData\Local\JetBrains\Installations\ReSharperPlatformVs15_****). Modifications there have the same effect.

 

Opt-out a single project

If you want to use StyleCop in nearly every project, then you should only disable it for a specific project. All you need to do is to create a file called Settings.Stylecop in your project and add this content:

The next time you start Visual Studio the squiggly lines marking violations of the StyleCop rules are gone – but just for those projects you don’t want it.

 

Conclusion

A small line of configuration and StyleCop behaves as you want it. It’s much less work than to remove StyleCop altogether and much less annoying than to ignore the squiggly lines.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.