question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Solution-level stylecop.json?

See original GitHub issue

Hi. What if I want to use the same stylecop.json across all projects in the solution?
Iā€™ve tried to make solution folder, put there stylecop.json and add it as a link to every project, but quick action ā€œAdd file headerā€ still uses default style cop settings (Iā€™ve changed company name).

(Sorry, I canā€™t add ā€œquestionā€ tag to the issue)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

13reactions
sharwellcommented, Sep 20, 2018

šŸ“ If you use the name Directory.Build.props and place the file in a parent directory (e.g. Root/Source instead of Root/Source/Shared), the file will be automatically imported by MSBuild, removing the need to manually reference it. This is how dotnet/roslyn-sdk includes the file for everything below src/Tools/Microsoft.CodeAnalysis.Testing without needing to update all of the individual project files: https://github.com/dotnet/roslyn-sdk/blob/3e94c5fe1ee981a885c34e2e39383bc4420f2557/src/Tools/Microsoft.CodeAnalysis.Testing/Directory.Build.props#L50-L60

8reactions
Dennis-Petrovcommented, Sep 20, 2018

@kkorus, in addition to @sharwellā€™s answer. Finally I ended up with SharedProjectSettings.proj file (there are 250+ csproj in my sources). Itā€™s MSBuild project file, and it includes stylecop.json, as well as ruleset and other msbuild stuff:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <CodeAnalysisRuleSet>..\..\Shared\StyleCop.ruleset</CodeAnalysisRuleSet>    
  </PropertyGroup> 

  <ItemGroup>
    <AdditionalFiles Include="..\..\Shared\stylecop.json" Link="Properties\stylecop.json" />
  </ItemGroup>

  <!-- ... -->
</Project>

Particular csproj imports SharedProjectSettings.proj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <Import Project="..\..\Shared\SharedProjectSettings.proj" />

  <!-- ... -->
</Project>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Shared Stylecop.json Between Projects in Visual Studio
Step 1: Add a stylecop.json file Ā· Step 2: Add a Solution Folder Ā· Step 3a: Add Existing File to Project Ā· Step...
Read more >
net - Manage Microsoft and StyleCop code analysis rules ...
I followed this tutorial but to sum-up, here is what I did: Added a SolutionName.ruleset file at the solution level; Added a stylecop.json...
Read more >
StyleCop: Setting to use it for a Solution with multiple ...
The stylecop.json file is just a text file which can be placed at the solution level and can be shared by each project...
Read more >
StyleCop: A Detailed Guide to Starting and Using It
Learn how to use Stylecop to automate enforcement of code style. ... Second, you can add a stylecop.json file to your project to...
Read more >
EditorConfig versus analyzers - Visual Studio (Windows)
StyleCop analyzers are third-party analyzers installed as a NuGet package that check for style consistency in your code. In general, StyleCop rules let...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found