简体   繁体   English

通过FxCop规则文件配置团队系统代码分析

[英]Configuring Team System Code Analysis via a FxCop rules file

Is there anyway to configure the code analysis rules in Visual Studio Team System to match those in an FxCop configuration file and keep them in sync automatically? 无论如何,是否可以在Visual Studio Team System中配置代码分析规则以使其与FxCop配置文件中的规则匹配并使它们自动保持同步?

Not all the developers on the team have TS so keeping the rules we are currently running in an FxCop file is required so everyone can run the same set, but it would nice for those with to be able to run them in the IDE. 并非团队中的所有开发人员都拥有TS,因此需要将我们当前正在运行的规则保持在FxCop文件中,以便每个人都可以运行相同的集合,但是对于那些能够在IDE中运行它们的人来说将是一件很高兴的事情。 We're introducing static analysis to an existing project so turning on everything now isn't a useful option. 我们将静态分析引入到现有项目中,因此现在打开所有内容都不是一个有用的选择。 (We are not using Foundation Server for source control, if that makes any difference.) (如果有任何区别,我们不会使用Foundation Server进行源代码控制。)

With the release of TFS 2010 this has completely changed. 随着TFS 2010的发布,这已经完全改变。 There's now the ability to specify ruleset files in your project configuration. 现在可以在项目配置中指定规则集文件。 You can share these between projects or even between environments. 您可以在项目之间甚至环境之间共享它们。

You can use the CodeAnalysisProject property to specify an FxCop project file that defines the rules for a Visual Studio project. 您可以使用CodeAnalysisProject属性来指定FxCop项目文件,该文件定义了Visual Studio项目的规则。 However, in order for this to work correctly in VStudio, the FxCop project file can only contain rule specifications, not target assemblies, which means that you would probably need two versions of your FxCop project: one with targets and one without. 但是,为了使它在VStudio中正常运行,FxCop项目文件只能包含规则规范,而不能包含目标程序集,这意味着您可能需要FxCop项目的两个版本:一个带有目标,另一个不带有。

Given that you're presumably not activating large sets of rules at any given time, another approach would be to used a shared MSBuild targets file for specifying the rule list for VStudio. 假定您在任何给定时间都不激活大量规则,则另一种方法是使用共享的MSBuild目标文件来指定VStudio的规则列表。 Unless you automatically generate the targets file from the FxCop file, this would require a bit more manual update work, but that would still represent very little effort at any given rule activation. 除非您从FxCop文件自动生成目标文件,否则这将需要更多的手动更新工作,但是对于任何给定的规则激活,这仍将花费很少的精力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM