6

I recently installed Visual Sudio 2015 and was able to run code analysis for the solution with the following command:

msbuild.exe MySolution.sln /p:RunCodeAnalysis=true

where /p:RunCodeAnalysis=true performs the code analysis. Actually this calls the FxCopCmd.exe located in

C:\Program Files(x86)\Microsoft Visual Studio 14.0\Team Tools\Static AnalysisTools\FxCop\FxCopCmd.exe

Code Analysis was meant to replace FxCop, but actually Code Analysis executes itself FxCopCmd.exe

Maybe I miss something, but what is the difference between VS Code Analysis and FxCop?

Pinte Dani
  • 1,989
  • 3
  • 28
  • 35

1 Answers1

11

FxCop and VS Code Analysis are essentially the same thing. They use the same core analysis engine (triggered via fxcopcmd.exe) and ship with the same core set of rules. Besides UI distinctions, the main difference betweeen FxCop and VS Code Analysis is that the latter includes some extra rules (in the DataflowRules.dll, MaintainabilityRules.dll, and ReliabilityRules.dll assemblies), plus a dataflow analysis engine that supports a subset of these additional rules.

Nicole Calinoiu
  • 20,843
  • 2
  • 44
  • 49
  • That makes sense, but as far as I can see, when I execute for example: `msbuild.exe MySolution.sln /p:RunCodeAnalysis=true`(which starts also code analysis), this actually starts the `C:\Program Files(x86)\Microsoft Visual Studio 14.0\Team Tools\StaticAnalysisTools\FxCop\FxCopCmd.exe` command. Is this not the same as executing FxCop directly? – Pinte Dani Nov 23 '15 at 17:41
  • Not quite sure what you're asking here... MSBuild launches `fxcopcmd.exe` via a custom MSBuild task, defined in the `fxcoptask.dll` assembly (which you'll probably find in the `C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis` folder). All this task does is construct a command line for `fxcopcmd.exe` by translating MSBuild properties into command line switch arguments. You certainly can construct that same command line manually if you so choose. – Nicole Calinoiu Nov 25 '15 at 15:13
  • 2
    This was what I wanted to know. So, either we execute code analysis by adding the `true` to the .csproj file OR execute `C:\Program Files(x86)\Microsoft Visual Studio 14.0\Team Tools\Static AnalysisTools\FxCop\FxCopCmd.exe` from the command line shall have the same result. – Pinte Dani Nov 25 '15 at 16:32