Search code examples
visual-studio-2010keyboard-shortcutsprojectstylecopsolution

How to make Stylecop to ignore a project in a solution?


When I choose Tools > Run Style Cop (Ctrl + Shift + Y) it runs StyleCop over all projects, even the one which are set to not build in the current solution configuration.

How to use this hotkey to check only the projects that I want?


Solution

  • Check out the Disable stylecop analysis for specific projects within solution question at Disable stylecop analysis for specific projects within solution as I think this is what you are looking for.

    To summarise, I managed to get this to work by adding the RulesEnabledByDefault global settings property to a Settings.StyleCop file which I put in the root folder of each project I did not want to be included in the StyleCop analysis.

    <StyleCopSettings Version="105">
      <GlobalSettings>
        <BooleanProperty Name="RulesEnabledByDefault">False</BooleanProperty>
      </GlobalSettings>
    </StyleCopSettings>
    

    If you make use of merged settings files, you may also have to include the MergeSettingsFiles global settings property. For example:

    <StyleCopSettings Version="105">
      <GlobalSettings>
        <StringProperty Name="MergeSettingsFiles">NoMerge</StringProperty>
        <BooleanProperty Name="RulesEnabledByDefault">False</BooleanProperty>
      </GlobalSettings>
    </StyleCopSettings>