How do I specify a ruleset from MSBuild

孤者浪人 提交于 2019-12-04 17:31:42

问题


After upgrading to VS 2010 MSBUILD /p:RunCodeAnalysis=true does not work as expected

msbuild solution.sln /p:RunCodeAnalysis=true

To get faster builds we removed the CODE_ANALYSIS constant for the DEBUG build. But that means thet when running the above msbuild command, it defauls to all rules, instead of using the ruleset we specified in on the "Code Analysis" tab on the project property page.

So now I need to build in release mode to run code analasis (which has the CODE_ANALYSIS constant defined):

msbuild solution.sln /p:RunCodeAnalysis=true /p:Configuration=release

This however means we get a release build on our dev machines. And this has some side effects in our setup.

Question: How do I specify the rulset from a command line. I was hoping something like:

msbuild solution.sln /p:RunCodeAnalysis=true /p:foobar=rules.ruleset

回答1:


You'll have to use the CodeAnalysisRuleSet property.

msbuild solution.sln /p:RunCodeAnalysis=true;CodeAnalysisRuleSet=GlobalizationRules.ruleset

Here is the predefined ruleset list :

  • AllRules.ruleset
  • BasicCorrectnessRules.ruleset
  • BasicDesignGuidelineRules.ruleset
  • ExtendedCorrectnessRules.ruleset
  • ExtendedDesignGuidelineRules.ruleset
  • GlobalizationRules.ruleset
  • MinimumRecommendedRules.ruleset
  • SecurityRules.ruleset


来源:https://stackoverflow.com/questions/3178537/how-do-i-specify-a-ruleset-from-msbuild

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!