Specify a project-specific custom dictionary for FxCop build tasks and Visual Studio Team System static code analysis

How to use a project-specific FxCop custom dictionary with Visual Studio Code Analysis by linking the dictionary into each project and configuring CodeAnalysisDictionary in the csproj file.

Using a project-specific custom dictionary for FxCop and FxCop build tasks is very simple. The FxCopCmd call in the FxCop-target offers the parameter /dictionary:<DictionaryName> for that.

But for Visual Studio a little bit more steps are needed. And these steps must me gone for all projects.

Add the custom dictionary as a link to each project. I organize such links under the special Properties-folder. So normally these links don’t violate my eyes ;-)

Next step requires editing of the .csproj-files. Either you open these files with an other editor or you unload the projects and edit these files with Visual Studio.

The following lines must inserted for a custom dictionary named FxCop.CustomDictionary.xml:

<ItemGroup>
    <CodeAnalysisDictionary Include="..\FxCop.CustomDictionary.xml">
        <Link>Properties\FxCop.CustomDictionary.xml</Link>
    </CodeAnalysisDictionary>
</ItemGroup>