Wraps the StyleCopConsole class to provide a mechanism for scanning files for StyleCop compliance.

Valid TaskActions are:

Scan (Required: SourceFiles, SettingsFile Optional: ShowOutput, ForceFullAnalysis, CacheResults, logFile, OutputFileOutput: Succeeded, ViolationCount, FailedFiles)

Remote Execution Support: No

Namespace: MSBuild.ExtensionPack.CodeQuality
Assembly: MSBuild.ExtensionPack.StyleCop (in MSBuild.ExtensionPack.StyleCop.dll) Version: 3.5.0.0

Examples

Xml Copy imageCopy
<Project ToolsVersion="3.5" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
        <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath>
    </PropertyGroup>
    <Import Project="$(TPath)"/>
    <Target Name="Default">
        <!-- Create a collection of files to scan -->
        <CreateItem Include="C:\Demo\**\*.cs">
            <Output TaskParameter="Include" ItemName="StyleCopFiles"/>
        </CreateItem>
        <!-- Run the StyleCop MSBuild task -->
        <MSBuild.ExtensionPack.CodeQuality.StyleCop TaskAction="Scan" SourceFiles="@(StyleCopFiles)" ShowOutput="true" ForceFullAnalysis="true" CacheResults="false" logFile="C:\StyleCopLog.txt" SettingsFile="C:\Program Files (x86)\StyleCop 4.5\Settings.StyleCop">
            <Output TaskParameter="Succeeded" PropertyName="AllPassed"/>
            <Output TaskParameter="ViolationCount" PropertyName="Violations"/>
            <Output TaskParameter="FailedFiles" ItemName="Failures"/>
        </MSBuild.ExtensionPack.CodeQuality.StyleCop>
        <Message Text="Succeeded: $(AllPassed), Violations: $(Violations)"/>
        <!-- FailedFile format is:
        <ItemGroup>
            <FailedFile Include="filename">
                <CheckId>SA Rule Number</CheckId>
                <RuleDescription>Rule Description</RuleDescription>
                <RuleName>Rule Name</RuleName>
                <LineNumber>Line the violation appears on</LineNumber>
                <Message>SA violation message</Message>
            </FailedFile>
        </ItemGroup>-->
        <Message Text="%(Failures.Identity) - Failed on Line %(Failures.LineNumber). %(Failures.CheckId): %(Failures.Message)"/>
    </Target>
</Project>

Inheritance Hierarchy

System..::..Object
  Microsoft.Build.Utilities..::..Task
    MSBuild.ExtensionPack..::..BaseTask
      MSBuild.ExtensionPack.CodeQuality..::..StyleCop

See Also