Visual Studio Integration of FxCop

Switch View :
ScriptFree
Visual Studio Integration of FxCop

To integrate FxCopCmd into Visual Studio, you must configure Visual Studio to run FxCopCmd as an external tool. After it is configured, FxCopCmd uses the /console and /consoleXsl options to send an abbreviated analysis report, including source code information if available, to the Output window in Visual Studio.

To set up FxCop as an external tool in Visual Studio

  • On the Tools menu, click External Tools, and then click Add.

The External Tools configuration dialog box is displayed. The following screen shot shows the dialog box after the steps in this procedure have been completed.

FxCop Cmd Visual Studio External Tool

FxCop appears on the Tools menu.

After you successfully build your project, you can perform an FxCop analysis without leaving the integrated development environment (IDE). To do this, click FxCop on the Tools menu. Make sure the Output window is visible; this is where the analysis output is displayed. The following screen shot shows the IDE with the output of an FxCopCmd analysis displayed in the Output window.

FxCop Cmd Visual Studio Output

If source code information is available for the programming element that caused a message to be generated, the list item for that element in the analysis report starts with the source code file and line number information for the element. Clicking the item will move the cursor to the corresponding line in the Code Editor. For more information, see Analysis Reports.

Community Content

darkroastjava
GAC dependencies
How to configure the tool to use existing GAC assemblies where necessary to resolve dependencies?

Jos
Here are the instructions to set up the dialog from the FxCop documentation

1. In the Title text box, type FxCop.
2. To set the value of the Command text box, browse to the location where FxCop is installed, and select FxCopCmd.exe.
3. In the Arguments text box, specify /console (or /c) in addition to any command-line options you use when running the analysis from the command line. The value of a command-line option must be enclosed in quotation marks if the value contains any spaces.
4. Set the Initial Directory to the location where FxCopCmd should start.
5. Select the Use Output window check box.
6. Click OK.
In particular the Arguments box should be filled so:

/c /f:$(TargetPath) /d:$(BinDir) /r:"c:\Program Files\Microsoft FxCop 1.36\Rules"

Replace c:\Program Files with another path if FxCop is not installed on your c: drive.
Replace Microsoft FxCop 1.36 with the right name if you're using another version.


lost_ca
Configuration Parameters
It would be nice to see the parameters as text. We can't see everything in the current screenshot.