如何集成FxCop和VS 2008?

发布于 2024-07-19 09:15:23 字数 255 浏览 3 评论 0原文

如果这是重复的问题,请指出正确的链接,我将删除该问题。

我知道在 VS Team System 中我可以使用代码分析,但我使用的是 VS Professional。

您能告诉我如何集成 FxCop 和 Visual Studio 吗? 我不想将 FxCopCmd.exe 添加到我的构建后事件中以在每次编译时运行 FxCop。 当我通过右键单击解决方案资源管理器中的项目进行选择时,我希望能够运行 FxCop。

感谢您的帮助。

If this is duplicated question, please point me to the proper link and I'll delete this question.

I know that in VS Team System I can use Code Analysis but I'm using VS Professional.

Can you tell me how I can integrate FxCop and Visual Studio? I don't want to add FxCopCmd.exe to my Post-build events to run FxCop with every compilation.
I want to be able to run FxCop when I choose by right clicking on the project in Solution Explorer.

Thanks for your help.

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

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

发布评论

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

评论(3

甜是你 2024-07-26 09:15:23

我花了一段时间才终于弄清楚。 这并不理想,但它有效。

更新:
我使用 分步说明创建帖子

感谢 aamit,他提供了使我走上正轨的链接,甚至是 MSDN 文章中的解决方案不起作用。 给他+1; 他应得的。

1.) 在 FxCop GUI 中保存您的项目。

重要

  • : 将项目保存在同一目录中
    你的解决方案在哪里。
  • b. 将 FxCop 项目名称指定为
    与您的解决方案名称相同并且
    包括 .sln 扩展名。

例如:如果您的解决方案名称为 MySolution.sln,则 FxCop 项目名称将为 MySolution.sln.FxCop

2.) 在 Visual Studio 中选择工具 -> 外部工具

3.) 在外部工具对话框中输入以下信息:

  • 标题:FxCop
  • 命令:C:\Program Files\Microsoft
    FxCop 1.36\FxCopCmd.exe
  • 参数:/c
    /p:"$(SolutionDir)\$(SolutionFileName).fxcop"
    /cXsl:"C:\Program Files\Microsoft
    FxCop 1.36\Xml\VSConsoleOutput.xsl"
  • 初始目录:C:\Program
    Files\Microsoft FxCop 1.36

确保选中“使用输出窗口”复选框。

就是这样。 它对我有用,我希望它对你也有用。

It took awhile by I finally figure it out. It's not ideal but it works.

Update:
I create a post with step by step instructions:

Thanks to aamit, who provided the link that put me on the right track even that solution in MSDN article doesn't work. Give him +1; he deserves it.

1.) In FxCop GUI save your project.

IMPORTANT:

  • a. Save project in the same directory
    where your solution is.
  • b. Give the FxCop project name the
    same as your solution name and
    include the .sln extension.

For example: If your solution name is MySolution.sln, the FxCop project name is going to be MySolution.sln.FxCop.

2.) In Visual Studio select Tools -> External Toos

3.) Enter following information in External Tools dialog box:

  • Title: FxCop
  • Command: C:\Program Files\Microsoft
    FxCop 1.36\FxCopCmd.exe
  • Arguments: /c
    /p:"$(SolutionDir)\$(SolutionFileName).fxcop"
    /cXsl:"C:\Program Files\Microsoft
    FxCop 1.36\Xml\VSConsoleOutput.xsl"
  • Initial directory: C:\Program
    Files\Microsoft FxCop 1.36

Make sure that "Use Output window" checkbox is checked.

That's it. It works for me I hope it's going to work for you.

风和你 2024-07-26 09:15:23

如何将 FxCop 设置为 Visual Studio 中的外部工具? 链接如下:

http://msdn.microsoft.com/ en-us/library/bb429389(VS.80).aspx

How about setting up FxCop as an external tool in Visual Studio? Here's the link:

http://msdn.microsoft.com/en-us/library/bb429389(VS.80).aspx

披肩女神 2024-07-26 09:15:23

我运行一个与 Vadim 非常相似的命令作为项目的构建后事件。 这样,我一重新编译就会收到 FxCop 错误。 但我们的命令几乎是一样的; 很高兴知道世界上至少有两个人得出了相同的结论!

这些错误确实显示在 Visual Studo 的错误列表窗格中。

"%ProgramFiles%\Microsoft FxCop 1.36\FxCopCmd.exe"
/file:"$(TargetPath)" 
/console
/dictionary:"$(SolutionDir)Res\FxCop\CustomDictionary.xml"
/searchgac 
/ignoregeneratedcode

/dictionary 参数;它仅指向我的自定义字典文件之一,因为 FxCop 将一些变量名称标记为匈牙利表示法,而实际上它们不是。为了便于阅读,我还对命令进行了换行。)

(您可以省略 构建时间稍长一些,但很高兴立即看到错误并根据项目定制命令设置。 祝你好运!

I run a command very similar Vadim's as a Post-Build event for the project. That way, I get the FxCop errors as soon as I recompile. But our commands are pretty much the same; nice to know at least two people in the world reached the same conclusion!

The errors do show up in Visual Studo's Error List pane.

"%ProgramFiles%\Microsoft FxCop 1.36\FxCopCmd.exe"
/file:"$(TargetPath)" 
/console
/dictionary:"$(SolutionDir)Res\FxCop\CustomDictionary.xml"
/searchgac 
/ignoregeneratedcode

(You can omit the /dictionary argument; it just points to one of my custom dictionary files since FxCop flags a few variable names as Hungarian notation when they aren't. I also line-wrapped the command for readability.)

It does make the build a little longer, but it's nice to see the errors right away and to tailor the command settings per project. Good luck!

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