views:

49

answers:

1

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"&gt;

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

+5  A: 

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

Steven
that was it! thanks.
justin.m.chase