在解决方案级别禁止警告.将警告视为解决方案级别的错误 [英] Suppress warning on solution level. Treat warning as error on solution level

查看:153
本文介绍了在解决方案级别禁止警告.将警告视为解决方案级别的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的团队设定全局规则.我们在C#项目中使用带有TFS的VS2012.我想禁止显示某些警告,并将某些警告视为错误.我找到了在项目级别执行此操作的方法-项目属性->构建"选项卡.

但是我们有数百个项目的解决方案,我正在寻找一种更简单的方法来在全球范围内设置这些规则.

解决方案

解决方案只是项目的(相当愚蠢的)容器.如果您在文本编辑器中打开它,您会很快看到您无法扩展它,只能添加项目/项目.

您想要的是一个或多个公共msbuild文件,这些文件指定了所使用的编译器/链接器/任何工具的所有必需选项,并在每个项目中将其Import都指定了.我们已经使用了多年,它非常方便(尽管便利的一部分可能是我们还编写了一个小的工具来生成项目文件以自动导入全局属性,所以我们不必手动对其进行处理)

或者,您可以添加计算机范围的文件,在$(MSBuildToolsPath)\ Microsoft.CSharp.targets中查找以查看将这些文件放置在何处.我不会在这里复制/粘贴内容,但是第一行基本上是检查$(MSBuildExtensionsPath)\ $(MSBuildToolsVersion)\ $(MSBuildThisFile)\ ImportBefore中是否存在用户定义的文件,如果是,则在所有常见的msbuild东西之前全部导入.同样,Microsoft.CSharp.targets的末尾包含类似的逻辑,可以在所有常见的msbuild内容之后导入文件.

I am trying to set global rules for my team. We are using VS2012 with TFS for our C# projects. I'd like to suppress some of the warnings and also treat some of the warnings as errors. I found the way to do it on the project level - project properties -> build tab.

But we have solution with more than hundred projects and I am looking for some easier way to set those rules globally.

解决方案

A solution is just a (pretty dumb) container for projects. If you open it in a text editor you'll quickly see you can't extend it, only add projects/items.

What you want is one or more common msbuild files specifying all needed options for compiler/linker/whatever tools you use, and Import it in every single project. We've been using this for years and it's very convenient (though part of the convenience is probably we also wrote a small tool to generate project files to automatically import the global properties so we don't have to mess with them manually)

Alternatively you could add a machine wide file, look in $(MSBuildToolsPath)\Microsoft.CSharp.targets to see where to place those files. I'm not going to copy/paste the content here, but the very first lines basically check if there are user definded files in eg $(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportBefore and if so they're all imported before all common msbuild stuff. Likewise the end of the Microsoft.CSharp.targets contains similar logic to import files after all common msbuild stuff.

这篇关于在解决方案级别禁止警告.将警告视为解决方案级别的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆