问题描述
升级到VS 2010 MSBUILD后/p:RunCodeAnalysis = true无法按预期工作
After upgrading to VS 2010 MSBUILD /p:RunCodeAnalysis=true does not work as expected
msbuild solution.sln /p:RunCodeAnalysis=true
为了获得更快的构建,我们删除了DEBUG构建的CODE_ANALYSIS常量.但这意味着在运行上述msbuild命令时,它会违背所有规则,而不是使用我们在项目属性页的代码分析"选项卡上指定的规则集.
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.
所以现在我需要以发布模式构建以运行代码分析(已定义CODE_ANALYSIS常量):
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.
问题:如何从命令行指定rulset.我希望是这样的:
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
推荐答案
您将不得不使用CodeAnalysisRuleSet
属性.
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
AllRules.ruleset
BasicCorrectnessRules.ruleset
BasicDesignGuidelineRules.ruleset
ExtendedCorrectnessRules.ruleset
ExtendedDesignGuidelineRules.ruleset
GlobalizationRules.ruleset
MinimumRecommendedRules.ruleset
SecurityRules.ruleset
这篇关于如何从MSBuild指定规则集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!