Skip to content

Commit e71ebb3

Browse files
authored
Merge pull request #2644 from ngeor/master
Added documentation on cross-solution configuration.
2 parents 715f8cc + 6115cdf commit e71ebb3

1 file changed

Lines changed: 46 additions & 1 deletion

File tree

documentation/Configuration.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ The following properties are used to configure copyright headers in StyleCop Ana
390390
| `copyrightText` | `"Copyright (c) {companyName}. All rights reserved."` | 1.0.0 | Specifies the default copyright text which should appear in copyright headers |
391391
| `xmlHeader` | **true** | 1.0.0 | Specifies whether file headers should use standard StyleCop XML format, where the copyright notice is wrapped in a `<copyright>` element |
392392
| `variables` | n/a | 1.0.0 | Specifies replacement variables which can be referenced in the `copyrightText` value |
393-
| `headerDecoration` | n/a | 1.1.0 | This value can be set to add a decoration for the header comment so headers look similar to the ones generated by the StyleCop Classic ReSharper fix |
393+
| `headerDecoration` | n/a | 1.1.0 | This value can be set to add a decoration for the header comment so headers look similar to the ones generated by the StyleCop Classic ReSharper fix |
394394

395395
#### Configuring Copyright Text
396396

@@ -575,3 +575,48 @@ File naming convention | Expected file name
575575
-----------------------| ------------------
576576
stylecop | Class1{T1,T2,T3}.cs
577577
metadata | Class1`3.cs
578+
579+
## Sharing configuration among solutions
580+
581+
It is possible to define your preferred configuration once and reuse it across multiple independent projects. This involves rolling out your own NuGet package,
582+
which will contain the `stylecop.json` configuration and potentially a custom ruleset file. A custom `.props` file glues that configuration to any project
583+
that wil use the NuGet package.
584+
585+
Example nuspec file:
586+
587+
```xml
588+
<?xml version="1.0"?>
589+
<package>
590+
<metadata>
591+
<id>acme.stylecop</id>
592+
<version>1.0.0</version>
593+
<dependencies>
594+
<dependency id="StyleCop.Analyzers" version="1.0.2" />
595+
</dependencies>
596+
</metadata>
597+
<files>
598+
<file src="stylecop.json" target="" />
599+
<file src="acme.stylecop.ruleset" target="" />
600+
<file src="acme.stylecop.props" target="build" />
601+
</files>
602+
</package>
603+
```
604+
605+
Example props file:
606+
607+
```xml
608+
<?xml version="1.0" encoding="utf-8"?>
609+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
610+
<PropertyGroup>
611+
<CodeAnalysisRuleSetLocation Condition=" '$(NuGetPackageRoot)' != '' ">$(NuGetPackageRoot)acme.stylecop\1.0.0</CodeAnalysisRuleSetLocation>
612+
<CodeAnalysisRuleSetLocation Condition=" '$(CodeAnalysisRuleSetLocation)' == '' and '$(SolutionDir)' != '' ">$(SolutionDir)packages\acme.stylecop.1.0.0</CodeAnalysisRuleSetLocation>
613+
<CodeAnalysisRuleSetLocation Condition=" '$(CodeAnalysisRuleSetLocation)' == '' ">$([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))\packages\acme.stylecop.1.0.0</CodeAnalysisRuleSetLocation>
614+
</PropertyGroup>
615+
<PropertyGroup>
616+
<CodeAnalysisRuleSet>$(CodeAnalysisRuleSetLocation)\acme.stylecop.ruleset</CodeAnalysisRuleSet>
617+
</PropertyGroup>
618+
<ItemGroup>
619+
<AdditionalFiles Include="$(CodeAnalysisRuleSetLocation)\stylecop.json" Link="stylecop.json" />
620+
</ItemGroup>
621+
</Project>
622+
```

0 commit comments

Comments
 (0)