如何强制MSBuild在不重新编译的情况下运行代码分析 [英] How to force MSBuild to run Code Analysis without recompiling

查看:132
本文介绍了如何强制MSBuild在不重新编译的情况下运行代码分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,仅对已编译的项目进行代码分析.因此,当我从命令行运行MSBuild时,它仅第一次运行代码分析.在随后的调用中,将跳过代码分析.

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.

背景:我想评估CA规则,看看打开规则时我们的代码中会有多少警告.为此,我不想重新编译所有内容(这需要一些时间),而只是重新运行代码分析.你怎么能做到这一点?

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?

我正在使用Visual Studio 2013和MSBuild 12.0.

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

推荐答案

似乎

  1. del /s *.lastcodeanalysissucceeded
  2. msbuild DesktopBuild.proj /p:RunCodeAnalysis=true
  1. del /s *.lastcodeanalysissucceeded
  2. 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.

这篇关于如何强制MSBuild在不重新编译的情况下运行代码分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆