Specify a custom dictionary for FxCop and Visual Studio source analysis

Posted by Marko Apfel on Geeks with Blogs See other posts from Geeks with Blogs or by Marko Apfel
Published on Tue, 11 May 2010 15:46:53 GMT Indexed on 2010/05/11 16:04 UTC
Read the original article Hit count: 398

Filed under:

Renaming the default custom dictionary from CustomDictionary.xml to an other name – for instance FxCop.CustomDictionary.xml needs some additional changes to work in involved applications.

Visual Studio Team System code analysis

For Visual Studio Team System code analysis this file should be added as a link to all projects and setted to be the Build Action CodeAnalysisDirectory.

Build target

In a build target the command line tool FxCopCmd should be called with the /dictionary parameter:

<Target Name="FxCop">
  <Exec
      Command="&quot;$(ProjectDir)..\..\build\FxCop\FxCopCmd.exe&quot;
        /file:&quot;$(TargetPath)&quot;
        /project:&quot;$(ProjectDir)..\EsriDE.SfgPraxair.FxCop&quot; 
        /directory:&quot;$(ProjectDir)..\..\lib\Esri.ArcGIS&quot; 
        /directory:&quot;$(ProjectDir)..\..\lib\Microsoft&quot; 
        /dictionary:&quot;$(ProjectDir)..\FxCop.CustomDictionary.xml&quot; 
        /out:&quot;$(OutDir)..\$(ProjectName).FxCopReport.xml&quot; 
        /console /forceoutput /ignoregeneratedcode">
  </Exec>
  <Message Text="FxCop finished." />
</Target>

FxCop-GUI (standalone application)

In FxCop-GUI is no option to specify an own file name – but you could add a hint in the FxCop project file.

Open your this file and look for the line:

<CustomDictionaries SearchFxCopDir="True" SearchUserProfile="True" SearchProjectDir="True" />

Then change it to:

<CustomDictionaries SearchFxCopDir="True" SearchUserProfile="True" SearchProjectDir="True">
  <CustomDictionary Path="FxCop.CustomDictionary.xml"/>
</CustomDictionaries>

Ready :-)

© Geeks with Blogs or respective owner