How do I specify a ruleset from MSBuild
Asked Answered
F

1

16

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
Fir answered 5/7, 2010 at 9:49 Comment(0)
S
30

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
Sigmund answered 5/7, 2010 at 12:15 Comment(1)
The ruleset can also be a link to a file. For example: /p:RunCodeAnalysis=true;CodeAnalysisRuleSet="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\ExtendedDesignGuidelineRules.ruleset".Philippine

© 2022 - 2024 — McMap. All rights reserved.