FxCop Class | MSBuild Extension Pack Help 4.0.12.0 |
The FxCop task provides a basic wrapper over FxCopCmd.exe. See http://msdn.microsoft.com/en-gb/library/bb429449(VS.80).aspx for more details.
Valid TaskActions are:
Analyse (Required: Project and / or Files, OutputFile Optional: DependencyDirectories, Imports, Rules, ShowSummary, UpdateProject, Verbose, UpdateProject, LogToConsole, Types, FxCopPath, ReportXsl, OutputFile, ConsoleXsl, Project, SearchGac, IgnoreInvalidTargets, Quiet, ForceOutput, AspNetOnly, IgnoreGeneratedCode, OverrideRuleVisibilities, FailOnMissingRules, SuccessFile, Dictionary, Ruleset, RulesetDirectory, References, AssemblyCompareMode Output: AnalysisFailed, OutputText, ExitCode)
Remote Execution Support: NA
Inheritance Hierarchy
MSBuild.ExtensionPackBaseTask
MSBuild.ExtensionPack.CodeQualityFxCop
Namespace: MSBuild.ExtensionPack.CodeQuality
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 4.0.0.0
The FxCop type exposes the following members.
Constructors
Name | Description | |
---|---|---|
FxCop |
Properties
Name | Description | |
---|---|---|
AnalysisFailed |
Gets AnalysisFailed. True if FxCop logged Code Analysis errors to the Output file.
| |
AspNetOnly |
Set to true to analyze only ASP.NET-generated binaries and honor global suppressions in App_Code.dll for all assemblies under analysis. Default is false
| |
AssemblyCompareMode |
Set the assembly comparison mode. Supports None, StrongName, StrongNameIgnoringVersion. Default is StrongName.
| |
ConsoleXsl |
Sets the ConsoleXsl (/consoleXsl option)
| |
DependencyDirectories |
Sets the DependencyDirectories :(/directory option)
| |
Dictionary |
Sets the custom dictionary used by spelling rules.Default is no custom dictionary
| |
ExitCode |
The exit code returned from FxCop
| |
FailOnMissingRules |
Set to true to treat missing rules or rule sets as an error and halt execution. Default is false
| |
Files |
Sets the Item Collection of assemblies to analyse (/file option)
| |
ForceOutput |
Set to true to write output XML and project files even in the case where no violations occurred. Default is false
| |
FxCopPath |
Sets the path to FxCopCmd.exe. Default is [Program Files]\Microsoft FxCop 1.36\FxCopCmd.exe
| |
IgnoreGeneratedCode |
Set to true to suppress analysis results against generated code. Default is false
| |
IgnoreInvalidTargets |
Set to true to silently ignore invalid target files. Default is false
| |
Imports |
Sets the name of an analysis report or project file to import (/import option)
| |
LogToConsole |
Set to true to direct analysis output to the console (/console option). Default is true
| |
OutputFile |
Set the name of the file for the analysis report
| |
OutputText |
Gets the OutputText emitted during analysis
| |
OverrideRuleVisibilities |
Set to true to run all overridable rules against all targets. Default is false
| |
Project |
Set the name of the .fxcop project to use
| |
Quiet |
Set to true to suppress all console output other than the reporting implied by /console or /consolexsl. Default is false
| |
References |
Sets the Item Collection of assemblies to reference (/reference option)
| |
ReportXsl |
Sets the ReportXsl (/outXsl: option)
| |
Rules |
Sets the location of rule libraries to load (/rule option). Prefix the Rules path with ! to treat warnings as errors
| |
Ruleset |
Specifies the Rule set to be used for the analysis. It can be a file path to the rule set file or the file name of
a built-in rule set. '+' enables all rules in the rule set; '-' disables all rules in the rule set; '=' sets rules
to match the rule set and disables all rules that are not enabled in the rule set
| |
RulesetDirectory |
Specifies the directory to search for rule set files that are specified by the Ruleset switch or are included by one of the specified rule sets.
| |
SearchGac |
Set to true to search the GAC for missing assembly references (/gac option). Default is false
| |
ShowSummary |
Set to true to display a summary (/summary option). Default is true
| |
SuccessFile |
Set to true to create .lastcodeanalysissucceeded file in output report directory if no build-breaking messages occur during analysis. Default is false
| |
Timeout |
Set the override timeout for analysis deadlock detection. Analysis will be aborted when analysis of a single item by a single rule exceeds the specified amount of time. Default is 0 to disable deadlock detection.
| |
Types |
Specifies the types to analyze
| |
UpdateProject |
Saves the results of the analysis in the project file. This option is ignored if the /project option is not specified (/update option)
| |
Verbose |
Set to true to output verbose information during analysis (/verbose option)
|
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)"/> <ItemGroup> <!--- Need to add to the dependencies because MSBuild.ExtensionPack.CodeQuality.StyleCop.dll references StyleCop --> <DependencyDirectories Include="c:\Program Files (x86)\MSBuild\Microsoft\StyleCop\v4.4"/> <!-- Define a bespoke set of rules to run. Prefix the Rules path with ! to treat warnings as errors --> <Rules Include="C:\Program Files (x86)\Microsoft Fxcop 10.0\Rules\DesignRules.dll"/> <Files Include="C:\Projects\MSBuildExtensionPack\Releases\4.0.1.0\Main\BuildBinaries\MSBuild.ExtensionPack.StyleCop.dll"/> </ItemGroup> <Target Name="Default"> <!-- Call the task using a collection of files and all default rules --> <MSBuild.ExtensionPack.CodeQuality.FxCop TaskAction="Analyse" Files="@(Files)" OutputFile="c:\fxcoplog1.txt"> <Output TaskParameter="AnalysisFailed" PropertyName="Result"/> </MSBuild.ExtensionPack.CodeQuality.FxCop> <Message Text="CA1 Failed: $(Result)"/> <!-- Call the task using a project file --> <MSBuild.ExtensionPack.CodeQuality.FxCop TaskAction="Analyse" Files="@(Files)" Project="C:\Projects\MSBuildExtensionPack\Releases\4.0.1.0\Main\Framework\XmlSamples\FXCop.FxCop" DependencyDirectories="@(DependencyDirectories)" OutputFile="c:\fxcoplog2.txt"> <Output TaskParameter="AnalysisFailed" PropertyName="Result"/> </MSBuild.ExtensionPack.CodeQuality.FxCop> <Message Text="CA2 Failed: $(Result)"/> <!-- Call the task using a collection of files and bespoke rules. We can access the exact failure message using OutputText --> <MSBuild.ExtensionPack.CodeQuality.FxCop TaskAction="Analyse" Rules="@(Rules)" Files="@(Files)" OutputFile="c:\fxcoplog3.txt" LogToConsole="true"> <Output TaskParameter="AnalysisFailed" PropertyName="Result"/> <Output TaskParameter="OutputText" PropertyName="Text"/> </MSBuild.ExtensionPack.CodeQuality.FxCop> <Message Text="CA3 Failed: $(Result)"/> <Message Text="Failure Text: $(Text)" Condition="$(Result) == 'true'"/> </Target> </Project>
See Also