使用规则集文件引用自定义代码分析规则库 [英] Referencing a custom code analysis rule library using a ruleset file
问题描述
关于Visual Studio 2010的自定义代码分析规则,没有太多容易找到的信息。尽管这是我对问题的了解...
There is not much easy-to-find information regarding custom code analysis rules for Visual Studio 2010. Although this is what I have found in regards to my question...
在CodePlex上的示例库中,展示了如何部署自定义代码分析规则库,该库使用设置项目以将库的DLL转储到 Program Files文件夹-> Microsoft Visual Studio 10.0->团队工具->静态分析工具-> FxCop->规则。
In the sample library on CodePlex it is shown how to deploy a custom code analysis rule library, which uses a Setup Project to dump the library's DLL into Program Files Folder -> Microsoft Visual Studio 10.0 -> Team Tools -> Static Analysis Tools -> FxCop -> Rules.
此外,这是一个非常有用的方法博克·坎斯特拉(Duke Kamstra)的博客帖子还建议将库的dll复制到%Program Files%\Microsoft Visual Studio 10.0\团队工具\静态分析工具\FxCop\规则。
Moreover, a very useful how-to blog post by Duke Kamstra also suggests to copy the library's dll into %Program Files%\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\Rules.
我的首选是避免将DLL粘贴在这样的全局位置。我想拥有与Visual Studio解决方案相关的DLL,这样,当我通过一些自定义代码分析规则更改来更新DLL时,就无需采取额外的步骤来使DLL的依赖关系保持最新。
My preference is to avoid sticking DLLs in such a global location. I wanted to have the DLL relative to my Visual Studio solutions, so that when I update the DLL with some custom code analysis rule changes then I need not take an extra step to keep dependencies of the DLL up-to-date.
对我来说,一个完美的解决方案是让我的自定义 *。ruleset 文件知道DLL的相对路径,但我一直没有成功
One perfect solution for me would be to have my custom *.ruleset file be aware of the relative path to the DLL, but I've been unsuccessful in doing so.
有任何建议吗?
推荐答案
在您的。规则集文件,您应该能够将相对路径添加到自定义规则DLL。例如:
In your .ruleset file, you should be able to add relative paths to the custom rule DLLs. e.g.:
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Sample" Description="Sample ruleset" ToolsVersion="10.0">
<RuleHintPaths>
<Path>..\Tools\FxCop\SomeRules.dll</Path>
<Path>..\Tools\FxCop\SomeOtherRules.dll</Path>
</RuleHintPaths>
...
</RuleSet>
这篇关于使用规则集文件引用自定义代码分析规则库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!