开发者

Is there a way to use one and only one settings file in stylecop?

Dinking around with stylecop settings files is getting annoying and messing with my repo structure. The repo is like this:

+ Trunk
    + src
        - ProjectA
        - ProjectB
        - ...
    + lib
        + Icons
        - ...
    + tools
        + NUnit
        + PartCover
        - Settings.StyleCop
        - 开发者_运维技巧...

I would like all projects/solutions to use the settings file from trunk/tools and no others (preferable I'd like all settings file for only projects in this trunk to use that settings file, but system wide is acceptable.

I must be the only person who finds the way stylecop deals with settings files and merging settings files to be really annoying, or I just don't understand it properly.


You can create a parent settings file, which applies to all projects in subfolders of the folder where the settings file is located:
Sharing StyleCop Settings Across Projects

BUT: that means you can't put the settings file into the trunk/tools folder.
You have to put it directly into the trunk folder instead.

But in my opinion, that's no problem. I did this in my own project as well:
The StyleCop assemblies and the target file are in a subfolder named \Libs\StyleCop, only the settings file itself is in the root folder. I can live with that.


If you really don't want to put the settings file in the Trunk folder, then you do have one other option: Replace the settings file in the StyleCop install directory.

Definitely 'an option of last resort', it makes the project validate differently on another computer that hasn't replaced the default StyleCop settings file.
I wouldn't recommend going down this path unless absolutely necessary.
The best way to make all projects use the same settings is by having the settings file in the topmost directory shared by all projects, that's all there is to it.


Updated

See this guide (under, Analyzing All Projects) if you are using StyleCop.Analyzers nuget package.


If you are using StyleCop Installer (this is the old version of SyleCop), this is how it can be done:

I have several projects in my solution and I am using my Web project's StyleCop setting as the main (global) setting :

Is there a way to use one and only one settings file in stylecop?

To do this, right click on any other project => StyleCop Settings

Is there a way to use one and only one settings file in stylecop?

Choose: Merge with the following Settings file and choose the your main project's settings.StyleCop (in my case the Web project's setting):

Is there a way to use one and only one settings file in stylecop?

That's it, now your main projects settings would be used for the other (child) project.

You can confirm this by opening your child project's StyleCop setting (note that it's hidden in VS):

Is there a way to use one and only one settings file in stylecop?

And you can see that is referencing your global setting. You can repeat these step for all other required projects.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜