如何在 Visual Studio 2010 Professional 中启用代码分析?

发布于 2024-09-02 05:09:09 字数 228 浏览 1 评论 0原文

我可以看到我们可以在 Visual Studio Team Systems 中启用代码分析。但我使用的是 Visual Studio 2010 Professional。

我们是否有任何选项可以在此版本中启用代码分析,或者我们可以将 FxCop 和 StyleCop 等任何工具与此版本集成以验证代码。

我希望在构建解决方案时就应该分析我的代码。

如果有人意识到这一点,请与我分享一些解决方案。

I can see that we can enable code analysis in Visual Studio Team Systems. But i am using Visual Studio 2010 Professional.

Do we have any option to enable code analysis in this version or can we integrate any tools like FxCop and StyleCop with this version for validating the code.

I am expecting my code should analysied the moment i build my solution.

If somebody aware of this, please share me some solution for this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

路弥 2024-09-09 05:09:09

您可以通过命令行将 FxCop 集成到解决方案的构建后事件中。

下载 FxCop 1.36 并将以下命令添加到构建后事件中:

"$(ProgramFiles)\Microsoft FxCop 1.36\FxCopCmd.exe" /c /p:"$(ProjectDir)\FxCop$(ConfigurationName).FxCop" /consolexsl:"$(ProgramFiles)\Microsoft FxCop 1.36\Xml\VSConsoleOutput.xsl"

通过 consolexsl 参数对输出进行格式化,以便将输出包含在 VisualStudio 构建错误和警告中。

我们创建了一个 FxCop 文件,用于指定 FxCop-Gui 的规则。该文件已在命令中加载。

You can integrate FxCop via Commandline in the post-build event of the solution.

Download FxCop 1.36 and add following command into the post-build event:

"$(ProgramFiles)\Microsoft FxCop 1.36\FxCopCmd.exe" /c /p:"$(ProjectDir)\FxCop$(ConfigurationName).FxCop" /consolexsl:"$(ProgramFiles)\Microsoft FxCop 1.36\Xml\VSConsoleOutput.xsl"

Via consolexsl parameter the output is formatted so that the output is included into you VisualStudio builderrors and -warnings.

We have created a FxCop file that specifies the rules with FxCop-Gui. That file is loaded in the command.

随梦而飞# 2024-09-09 05:09:09

查看此比较图表,从开始检查内置代码分析支持高级栏。

Check out this comparison chart, built-in code analysis support gets checked starting in the Premium column.

迷爱 2024-09-09 05:09:09

原始问题中还提到了 StyleCop,让我回答这部分:它也可以集成到构建链中,如 本文。当然,您必须使用 StyleCop 的当前路径/版本调整文章中提到的路径和目标(现在是 $(ProgramFiles)MSBuild\StyleCop\v4.7\StyleCop.Targets )。

为了使其开箱即用(源代码控制),我通常将目标文件、StyleCop 二进制文件复制到 SC 中的某个文件夹中(目标文件可以为此进行调整),并使用相对路径来引用它。这样可以避免创建任何环境变量,并且可以在空白机器上立即从 SC 构建项目。

There was also StyleCop mentioned in the original question, let me answer that part: it can be integrated into build chain too as described in this article. Sure you have to adjust path and target mentioned in article with current path/version of StyleCop (it's $(ProgramFiles)MSBuild\StyleCop\v4.7\StyleCop.Targets now).

To make it work out of box (source control), I usually copy targets file, StyleCop binaries into some folder in SC (target file can be adjusted for that), and use relative paths to reference it. This allows to avoid creating any environmental variables, and project can be build immediately from SC on blank machine.

陈甜 2024-09-09 05:09:09

您应该手动启用代码分析。遵循 链接在这里

You should enable Code Analysis manually. Follow the link here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文