您可以从 msbuild.exe 命令行关闭条件编译符号吗?
我们在 C# 组件中定义了 CODE_ANALYSIS,以便 FxCop 在我们的开发盒上构建它们时对其进行分析。我希望在 FxCop 在我们的构建系统中运行时将其关闭。构建系统显然使用 msbuild.exe 命令行命令。有没有办法修改此可执行文件中的条件编译符号?如果没有,有谁知道我的问题的任何其他可能的解决方案(除了手动关闭它)?
谢谢。
We have CODE_ANALYSIS defined in our C# components so that FxCop analyzes them when we build them on our development boxes. I would like to have FxCop turned off when it runs through our build system. The build system is obviously using the msbuild.exe command line command. Is there a way to modify the conditional compilation symbols from this executable? If not, does anyone know any other possible solutions to my problem (other than turning it off manually)?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
CODE_ANALYSIS 编译符号控制是否将代码中包含的 SuppressMessageAttribute 实例复制到已编译的程序集中。它不控制 FxCop 是否运行。如果您想要覆盖项目级 MSBuild 属性,例如 RunCodeAnalysis(它是控制 FxCop 是否在 MSBuild 下运行的野兽),您应该能够使用 MSBuild.exe /property 命令行开关。例如:
The CODE_ANALYSIS compilation symbol controls whether the SuppressMessageAttribute instances included in the code are copied into the compiled assembly. It does not control whether FxCop runs. If you want to override a project-level MSBuild property like RunCodeAnalysis (which is the beastie that controls whether FxCop runs under MSBuild), you should be able to use the MSBuild.exe /property command line switch. e.g.:
为什么需要关闭它们?设置项目的最佳方法是仅为调试配置定义 CODE_ANALYSIS。发布版本不会设置此值。这样,当您构建生产安装时,它们将不会有任何对 FxCop 的引用。
Why do you need to turn them off? The best way to set up the project is to define CODE_ANALYSIS for debug configurations only. The release version will not have this value set. That way, when you build production installs, they will not have any references to FxCop.