Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FxCop is not respecting my excludes

I am trying to incorporate FxCop directly into my build. I am using the MSBuild Community Tasks. I have a targets file like this:

<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>

It's working just fine, except that as I add [SuppressMessage] warnings they are still showing up in my output. I created a .fxcop project file and included the output assembly and tried to run it that way but the same thing happens. It seems like FxCop is not respecting my suppressions, any ideas?

Here's an example of a suppression that is not working (GlobalSuppressions.cs):

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

Which was generated by the fxcop tool. Any ideas?

like image 560
justin.m.chase Avatar asked Feb 27 '23 05:02

justin.m.chase


1 Answers

Did you add the CODE_ANALYSIS symbol to the conditional compilation symbols of your project?

like image 91
Steven Avatar answered Mar 10 '23 11:03

Steven