Tuesday, 11 August 2015

Using stylecop with Code analyzer in VS2015

As per the styplecop project the support for Visual studio 2015 is not yet ready. Not sure if there’ll be any support available in coming future because VS2015 now have it’s built-in code analyzer which can adapt to any provided Code analyzer and run the ruleset accordingly against the project code files.

To get the style cop running with Visual studio 2015 follow below steps:

Installing Stylecop.Analyzers(currently in Pre-release version) nuget package in Visual studio 2015 project. Make sure to select “include prerelease” checkbox before searching -

I like the new Nuget package manager, Professional.

After the installation of Stylecop.Analyzers Nuget package, Expand the Reference tree and look for the Analyzers -

Now Right click on it and select “Open Active Ruleset”. This will open up the list of Analyzers and their rule sets.


Now you can select and customize the Ruleset to run for your code. Now when you press save this will add a new file “<your projectname>.ruleset” with-in the project. This customized Ruleset file can be used across the projects.

Managing the Rulesets across Projects
To manage the Rulesets across the projects you can configure the mapping of Ruleset. See follow below steps:
1. Click on Analyze from Menu and select “Configure Code Analysis for solution


This will open a windows and provide the option to choose which Ruleset to run against each project. You can choose the same file that you have created for all projects. OR you can go for separate rulesets files for individual projects.


Now, that you have created a custom rule set file and setup the Ruleset for projects in a solution. Now you can launch the code analysis on Solution level.

Launching the Code analysis

Analyze –> Run Code Analysis for Solution (Allt + F11)

This should gives results in the Error window.

Now you have the code analysis results from your old friend styleCop. Hope this would help you util we hear from other sources.
Thanks to John Koerner’s post for guiding towards the stylecop.Analyzers nuget package thing.