C# – FxCop的不尊重我的排除

我正在尝试将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不尊重我的压抑,任何想法?

这是一个无效的抑制示例(GlobalSuppressions.cs):

[module: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "MetaSharp.Transformation.Lang")]

这是由fxcop工具生成的.有任何想法吗?

解决方法:

您是否将CODE_ANALYSIS符号添加到项目的条件编译符号中?

上一篇:c# – 如何在OS X和Linux上安装MSBuild?


下一篇:在Jenkins中集成Sonarqube