|
| 1 | +--- |
| 2 | +title: FxCop code analysis and FxCop analyzers |
| 3 | +ms.date: 09/06/2018 |
| 4 | +ms.prod: visual-studio-dev15 |
| 5 | +ms.technology: vs-ide-code-analysis |
| 6 | +ms.topic: overview |
| 7 | +helpviewer_keywords: |
| 8 | + - "code analysis FAQ" |
| 9 | +author: gewarren |
| 10 | +ms.author: gewarren |
| 11 | +manager: douge |
| 12 | +ms.workload: |
| 13 | + - "dotnet" |
| 14 | +--- |
| 15 | +# Frequently asked questions about FxCop and FxCop analyzers |
| 16 | + |
| 17 | +It can be a little confusing to understand the differences between legacy FxCop and FxCop analyzers. This article aims to address some of questions you might have. |
| 18 | + |
| 19 | +## What's the difference between legacy FxCop and FxCop analyzers? |
| 20 | + |
| 21 | +Legacy FxCop runs post-build analysis on a compiled assembly. It runs as a separate executable called **FxCopCmd.exe**. FxCopCmd.exe loads the compiled assembly, runs code analysis, and then reports the results (or *diagnostics*). |
| 22 | + |
| 23 | +FxCop analyzers are based on the .NET Compiler Platform ("Roslyn"). You [install them as a NuGet package](install-fxcop-analyzers.md#to-install-fxcop-analyzers-as-a-nuget-package) that's referenced by the project or solution. FxCop analyzers run source-code based analysis during compiler execution. FxCop analyzers are hosted within the compiler process, either **csc.exe** or **vbc.exe**, and run analysis when the project is built. Analyzer results are reported along with compiler results. |
| 24 | + |
| 25 | +> [!NOTE] |
| 26 | +> You can also [install FxCop analyzers as a Visual Studio extension](install-fxcop-analyzers.md#to-install-fxcop-analyzers-as-a-vsix). In this case, the analyzers execute as you type in the code editor, but they don't execute at build time. If you want to run FxCop analyzers as part of continuous integration (CI), install them as a NuGet package instead. |
| 27 | +
|
| 28 | +## Does the Run Code Analysis command run FxCop analyzers? |
| 29 | + |
| 30 | +No. When you select **Analyze** > **Run Code Analysis** in Visual Studio 2017, it executes static code analysis or legacy FxCop. **Run Code Analysis** has no effect on Roslyn-based analyzers, including the Roslyn-based FxCop analyzers. |
| 31 | + |
| 32 | +## Does the RunCodeAnalysis msbuild project property run analyzers? |
| 33 | + |
| 34 | +No. The **RunCodeAnalysis** property in a project file (for example, *.csproj*) is only used to execute legacy FxCop. It runs a post-build msbuild task that invokes **FxCopCmd.exe**. This is equivalent to selecting **Analyze** > **Run Code Analysis** in Visual Studio. |
| 35 | + |
| 36 | +## So how do I run FxCop analyzers then? |
| 37 | + |
| 38 | +To run FxCop analyzers, first [install the NuGet package](install-fxcop-analyzers.md) for them. Then build your project or solution from Visual Studio or using msbuild. The warnings and errors that the FxCop analyzers generate will appear in the **Error List** or the command window. |
| 39 | + |
| 40 | +## See also |
| 41 | + |
| 42 | +- [Overview of .NET Compiler Platform analyzers](roslyn-analyzers-overview.md) |
| 43 | +- [Get started with analyzers](fxcop-analyzers.yml) |
| 44 | +- [Install FxCop analyzers](install-fxcop-analyzers.md) |
0 commit comments