Q: Why does the RunFxCop task fail when I run MSBuild from the command line?

A: When you build from the command line, the build report may contain an error for the RunFxCop task that says, "The system cannot find the path specified." This is a known problem that is fixed in later releases. It occurs because the environment variable, FxCopDir, was not defined in this release. As a workaround, you can do one of the following:

  • Add the Environment Variable:
  1. In Control Panel, open System.  The System Properties dialog box appears.
  2. Click the Advanced tab, and then click Environment Variables. The Environment Variables dialog box appears.
  3. Under System variables, click New. The New System Variable dialog box appears.
  4. In the Variable name box, type FxCopDir.
  5. In the Variable value box, type (path), and then click OK.
  • Or, use MSBuild's /p command-line switch to provide the full path for FxCop:

msbuild /p:FxCopDir="C:\Program Files\Microsoft Visual Studio 8\Enterprise Developer Tools\Static Analysis Tools\FxCop"

Applicability: Visual Studio 2005 Beta 1 Refresh with Visual Studio 2005 Team System