Search code examples
c#msbuildprojectstylecopsolution

How to show all StyleCop warnings for a solution?


If I have 2 projects in my solution, and each one of them is configured to run StyleCop, MSBuild will show only warnings for a single project.

Isn't there a way to make it show warnings for every project?


Solution

  • You can use msbuidl and the msbuild extension pack, specifically: MSBuild.ExtensionPack.StyleCop.dll

    to analyse a path (alll the code here) e.g.

    and send the files to the task

    <MSBuild.ExtensionPack.CodeQuality.StyleCop
         TaskAction="Scan"
          ShowOutput="true"
          ForceFullAnalysis="true"
          CacheResults="false"
          SourceFiles="@(SourceFiles)"
          SettingsFile="$(SourceAnalysisSettingsFile)"
          ContinueOnError="false">
                 <Output TaskParameter="Succeeded" PropertyName="AllPassed"/>
                 <Output TaskParameter="ViolationCount" PropertyName="Violations"/>
                 <Output TaskParameter="FailedFiles" ItemName="Failures"/>
    
    </MSBuild.ExtensionPack.CodeQuality.StyleCop>
    

    Hope that gets you started.