By default, code analysis is only done for projects which are compiled. So when I run MSBuild from the command line, it runs code analysis only for the first time. On subsequent calls, code analysis is skipped.
Background: I want to evaluate CA rules and see how many warnings there would be in our code when turning on a rule. For that I don't want to recompile everything - which takes some time - but just re-run the code analysis. How can you achieve this?
I am using Visual Studio 2013 and MSBuild 12.0.
Even explicitely switching on code analysis does not help:
msbuild DesktopBuild.proj /p:RunCodeAnalysis=true
It seems that
del /s *.lastcodeanalysissucceeded
msbuild DesktopBuild.proj /p:RunCodeAnalysis=true
seems to work. The first step causes code analysis to "forget" about the previous runs and the second step forces it to run for every project, even if code analysis is not enabled in a project. If running this repeatedly, the already compiled projects won't be compiled again, only the code analysis is re-run.