Install FxCop analyzers in Visual Studio

Microsoft created a set of analyzers, called Microsoft.CodeAnalysis.FxCopAnalyzers, that contains the most important "FxCop" rules from legacy analysis. These analyzers check your code for security, performance, and design issues, among others.

You can install these FxCop analyzers either as a NuGet package or as a VSIX extension to Visual Studio. To learn about the pros and cons of each, see NuGet package vs. VSIX extension.

To install FxCop analyzers as a NuGet package

  1. Determine which analyzer package version to install, based on your version of Visual Studio.

  2. Install the package in Visual Studio, using either the Package Manager Console or the Package Manager UI.

    Note

    The nuget.org page for each analyzer package shows you the command to paste into the Package Manager Console. There's even a handy button to copy the text to the clipboard.

    NuGet.org page showing Package Manager Console command

    The analyzer assemblies are installed, and they appear in Solution Explorer under References > Analyzers.

    Analyzers node in Solution Explorer

FxCopAnalyzers package versions

Use the following guidelines to determine which version of the FxCop analyzers package to install for your version of Visual Studio:

Visual Studio version FxCop analyzer package version
Visual Studio 2019 (all versions)
Visual Studio 2017 version 15.8 and later
2.9.3
Visual Studio 2017 version 15.5 to 15.7 2.6.3
Visual Studio 2017 version 15.3 to 15.4 2.3.0-beta1
Visual Studio 2017 version 15.0 to 15.2 2.0.0-beta2
Visual Studio 2015 update 2 and 3 1.2.0-beta2
Visual Studio 2015 Update 1 1.1.0
Visual Studio 2015 RTW 1.0.1

To install FxCop analyzers as a VSIX

On Visual Studio 2017 version 15.5 and later, you can install the Microsoft Code Analysis 2017 extension that contains all of the FxCop analyzers for managed projects.

  1. In Visual Studio, select Tools > Extensions and Updates.

    The Extensions and Updates dialog box opens.

    Note

    Alternatively, download the extension directly from Visual Studio Marketplace.

  2. Expand Online in the left pane, and then select Visual Studio Marketplace.

  3. In the search box, type "code analysis", and look for the Microsoft Code Analysis 2017 extension.

    Microsoft Code Analysis 2017 extension

The Microsoft Code Analysis 2019 extension contains all of the FxCop analyzers for managed projects. To install this extension:

  1. In Visual Studio, select Extensions > Manage Extensions.

    The Manage Extensions dialog box opens.

    Note

    Alternatively, download the extension directly from Visual Studio Marketplace.

  2. Expand Online in the left pane, and then select Visual Studio Marketplace.

  3. In the search box, type "code analysis", and look for the Microsoft Code Analysis 2019 extension.

    Microsoft Code Analysis 2019 extension

  1. Select Download.

    The extension is downloaded.

  2. Select OK to close the dialog box, and then close all instances of Visual Studio to launch the VSIX Installer.

    The VSIX Installer dialog box opens.

    VSIX installer for Microsoft Code Analysis

  3. Select Modify to start the installation.

    After a minute or two, the installation completes.

  4. Select Close, then open Visual Studio again.

If you want to check whether the extension is installed, select Tools > Extensions and Updates. In the Extensions and Updates dialog box, select the Installed category on the left, and then search for the extension by name.

If you want to check whether the extension is installed, select Extensions > Manage Extensions. In the Manage Extensions dialog box, select the Installed category on the left, and then search for the extension by name.

See also