我正在尝试将FxCop直接合并到我的构建中。我正在使用MSBuild社区任务。我有这样一个目标文件:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<FxCopToolPath Condition="'$(FxCopToolPath)' == ''">$(MetaSharpLibPath)\FxCop</FxCopToolPath>
<FxCopCustomDictionary Condition="'$(FxCopCustomDictionary)' == ''">$(FxCopTooLPath)\CustomDictionary.xml</FxCopCustomDictionary>
<MSBuildCommunityTasksLib>..\MSBuild.Community.Tasks\MSBuild.Community.Tasks.dll</MSBuildCommunityTasksLib>
</PropertyGroup>
<UsingTask AssemblyFile="$(MSBuildCommunityTasksLib)" TaskName="MSBuild.Community.Tasks.FxCop" />
<Target Name="AfterBuild" >
<ItemGroup>
<FxCopRuleAssemblies Include="DesignRules.dll" />
<FxCopRuleAssemblies Include="GlobalizationRules.dll" />
<FxCopRuleAssemblies Include="InteroperabilityRules.dll" />
<FxCopRuleAssemblies Include="MobilityRules.dll" />
<FxCopRuleAssemblies Include="NamingRules.dll" />
<FxCopRuleAssemblies Include="PerformanceRules.dll" />
<FxCopRuleAssemblies Include="PortabilityRules.dll" />
<FxCopRuleAssemblies Include="SecurityRules.dll" />
<FxCopRuleAssemblies Include="SecurityTransparencyRules.dll" />
<FxCopRuleAssemblies Include="UsageRules.dll" />
<FxCopTargetAssembly Include="@(MainAssembly)" />
</ItemGroup>
<FxCop
ToolPath="$(FxCopToolPath)"
CustomDictionary="$(FxCopCustomDictionary)"
RuleLibraries="@(FxCopRuleAssemblies)"
TargetAssemblies="@(FxCopTargetAssembly)"
DependencyDirectories="@(ReferencePath)"
FailOnError="True"
ConsoleXslFileName="$(FxCopToolPath)\Xml\VSConsoleOutput.xsl"
DirectOutputToConsole="true" />
</Target>
</Project>
它工作得很好,只是当我添加[SuppressMessage]警告时,它们仍然显示在我的输出中。我创建了一个.fxcop项目文件并包含了输出程序集,并尝试以这种方式运行它,但同样的情况也发生了。看来FxCop不尊重我的压制,有什么想法吗?
[module: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "MetaSharp.Transformation.Lang")]
它是由fxcop工具生成的。有什么想法吗?