StyleCop Class | MSBuild Extension Pack Help 4.0.12.0 |
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
Inheritance Hierarchy
MSBuild.ExtensionPackBaseTask
MSBuild.ExtensionPack.CodeQualityStyleCop
Namespace: MSBuild.ExtensionPack.CodeQuality
Assembly: MSBuild.ExtensionPack.StyleCop (in MSBuild.ExtensionPack.StyleCop.dll) Version: 4.0.0.0
The StyleCop type exposes the following members.
Constructors
Name | Description | |
---|---|---|
StyleCop |
Properties
Name | Description | |
---|---|---|
CacheResults |
Sets a value indicating whether StyleCop should write cache files to disk after performing an analysis. Default is false.
| |
FailedFiles |
Gets the failed files collection
| |
ForceFullAnalysis |
Sets a value indicating whether StyleCop should ignore cached results and perform a clean analysis.
| |
LogFile |
Sets the log file.
| |
OutputFile |
Sets the path to the generated output file.
| |
SettingsFile |
Sets the path to the settings file to load.
| |
ShowOutput |
Sets a value indicating whether to ShowOutput. Default is false
| |
SourceFiles |
Sets the source files collection
| |
Succeeded |
Gets whether the scan succeeded.
| |
ViolationCount |
Gets the violation count.
|
Examples
<Project ToolsVersion="4.0" 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.7\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)" Importance="high"/> <!-- 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>
See Also