简体   繁体   English

在Visual Studio 2008中将Fxcop错误显示为编译错误

[英]Show Fxcop errors as compilation errors in Visual Studio 2008

Is there any way so that I get the Fxcop errors displayed as compilation errors in Visual Studio build? 有什么办法可以使Fxcop错误在Visual Studio构建中显示为编译错误?

PS - I dont want to integrate Fxcop into an MSBuild script. PS-我不想将Fxcop集成到MSBuild脚本中。 I just need it to be integrated into VS 2008, and when "Build Solution" is run, it should display the Fxcop errors if any. 我只需要将其集成到VS 2008中,并且在运行“生成解决方案”时,它应该显示Fxcop错误(如果有)。

Right-click on the project, choose Properties. 右键单击项目,选择“属性”。

On the Code Analysis tab, choose "Enable Code Analysis on Build". 在“代码分析”选项卡上,选择“在生成时启用代码分析”。

在此处输入图片说明

For an edition of Visual Studio that does not include integrated Code Analysis, you have a couple of options. 对于不包含集成代码分析的Visual Studio版本,您有两种选择。 The simplest is to run FxCop as a post-build event, redirecting output to the console: 最简单的是将FxCop作为构建后事件运行,将输出重定向到控制台:

"$(ProgramFiles)\\Microsoft FxCop 10.0\\FxCopCmd.exe" /file:"$(TargetPath)" /console

This will add the FxCop warnings and errors to your Visual Studio error list, and allow you to navigate to source code when context information is available for a violation. 这会将FxCop警告和错误添加到Visual Studio错误列表中,并在上下文信息可用于违规时允许您导航到源代码。 but that's pretty much it. 但这仅此而已。

If you want support for functionality like adding SuppressMessage attributes from the error list, you'll need a Visual Studio extension of some sort. 如果要支持功能,例如从错误列表中添加SuppressMessage属性,则需要某种Visual Studio扩展。 (That's how the integrated Code Analysis piece works.) (这就是集成的代码分析部分的工作方式。)

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

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