How to use the StyleCop Plugin with the Resharper

2019-08-15 17:41发布

问题:

We use Resharper with the StyleCop plugin. It works great inside Visual Studio without any problems.

Now I'd like to get statistics about our projects. I am building all our solutions from the command line and so far managed to get the output from the compiler (warnings) static code analysis (ex FxCop) and unit testing (results and coverage).

JetBrains offers a commandline tool that does code analysis for free (Link).

I'm using it and it works as expected.

The command line version does not recognize my StyleCop plugin and it's rules. That's obvious, it's a different folder. So I copied my plugins folder at

C:\Program Files (x86)\JetBrains\ReSharper\v8.2\Bin\Plugins\StyleCop 4.7

over from my Resharper installation into the command line tool's .\Bin\Plugins\StyleCop 4.7 and it works... the command line tool recognizes the plugin and loads it. However, the plugin then cannot find the StyleCop assemblies. They were default-installed into

C:\Program Files (x86)\StyleCop 4.7

Resharper itself in Visual Studio can somehow auto-detect them.

I tried copying the StyleCop assemblies to the same folder that the commandline exe is in. Nothing changed.

I tried copying the StyleCop assemblies next to the StyleCop Plugin assembly. That worked in a way. The StyleCop plugin found it's StyleCop assemblies, but the command line tool complained because it tried to load every single assembly in that folder as plugin.

So how do I get the command line tool to work with the StyleCop plugin?

If there is a better option, I do have a full license, I'm happy about any hint how to do this with the free command line tool or the normal Resharper full version as long as I can start it from a batch file without having to open the Visual Studio GUI.

回答1:

Current State

Resharper recognized this is a problem with their tool. The Issue # is RSRP-436208.

It's not fixed as of 2017.1.1.

Workaround

When a Nuget package ( extension .nupkg ) is found in the tool's folder, it is expanded automatically in some temporary location. It's assemblies are then used with the tool.

So any *.nupkg of a plugin that resides in the tool folder should work.