热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何整合FxCop和VS2008?-HowtointegrateFxCopandVS2008?

Ifthisisduplicatedquestion,pleasepointmetotheproperlinkandIlldeletethisquestion.如果

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.

我知道在VS Team System中我可以使用代码分析,但我正在使用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.

你能告诉我如何整合FxCop和Visual Studio吗?我不想将FxCopCmd.exe添加到我的Post-build事件中以便在每次编译时运行FxCop。我想通过右键单击解决方案资源管理器中的项目来选择运行FxCop。

Thanks for your help.

谢谢你的帮助。

3 个解决方案

#1


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.

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

1.) In FxCop GUI save your project.

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

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.
  • 湾为FxCop项目名称提供与解决方案名称相同的名称,并包含.sln扩展名。

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

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

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

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

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

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

  • Title: FxCop
  • Command: C:\Program Files\Microsoft FxCop 1.36\FxCopCmd.exe
  • 命令: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"
  • 参数:/ 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
  • 初始目录: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.

而已。它对我有用,我希望它对你有用。

#2


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

如何在Visual Studio中将FxCop设置为外部工具?这是链接:

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

#3


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!

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

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

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

"%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.)

(您可以省略/ dictionary参数;它只指向我的一个自定义词典文件,因为FxCop将一些变量名称标记为匈牙利表示法,而不是。我还将命令行换行以便于阅读。)

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!

它确实使构建时间更长,但很高兴立即看到错误并为每个项目定制命令设置。祝好运!


推荐阅读
author-avatar
美晶婚纱-璐璐_723
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有