[Source: http://geekswithblogs.net/EltonStoneman]

The static analysis of BizTalkCop runs on compiled BizTalk assemblies, and as BizTalk 2009 projects follow the standard Visual Studio format, it’s simple to include the rules for BizTalk projects in Visual Studio 2008.


1. Make the rules available to Visual Studio

The rules assembly BizTalkCop.Rules.dll needs to be in the static analysis directory of Visual Studio – by default:

C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Static Analysis Tools\FxCop\Rules

Either copy the assembly from an existing installation (which will be in C:\Program Files\Microsoft FxCop 1.36\Rules by default), or select the Rules path as the destination folder on a new install.

2. Enable the BizTalkCop rules for your project

In the project settings, select “Enable Code Analysis on Build”, and select the BizTalkCop rules:

Then when you run a build, the BizTalkCop messages will be shown as warnings:

If you’re particularly Draconian, you can set “Treat Warnings as Errors” for one or all BizTalkCop rules, so any failures are shown as errors, and will break the build.

Differences in Visual Studio and FxCop functionality

You can use Visual Studio’s Suppress Message functionality to ignore a particular rule for a particular artefact. Suppressing works for both the “In Project Suppression File” and the “In Source” options, but most of the source is generated so the suppressions will be lost when they change – adding to Project Suppression File is safer.

Visual Studio doesn’t allow you to configure rule values as FxCop does. The dynamic BizTalkCop rules which run against application bindings use configured values for the application name and management database, so they won’t function through Visual Studio. (See Introducing: BizTalkCop for information on configurable rules). Also if your standards differ from the default configured values, you’ll need to change the rules in code and rebuild to get the new values through Visual Studio.

A good compromise would be to use the static rules in Visual Studio at development time, then have a separate FxCop project which includes the dynamic rules, and runs as part of the build process once the BizTalk application has been deployed to the build/staging environment.