如何抑制特定的 MSBuild 警告 [英] How to suppress specific MSBuild warning

查看:40
本文介绍了如何抑制特定的 MSBuild 警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从命令行运行 MSBuild 时,有什么方法可以禁用特定的 MSBuild 警告(例如 MSB3253)?我的构建脚本通过以下方式调用 msbuild.exe:

Is there any way to disable specific MSBuild warning (e.g. MSB3253) when running MSBuild from command line? My build script calls msbuild.exe much the following way:

msbuild.exe MySolution.sln /t:Rebuild /p:Configuration=Release

我发现我可以使用 msbuild.exe 的另一个参数来抑制 C# 警告(例如 CS0618):

I've found out that I can suppress C# warnings (e.g. CS0618) using another parameter for msbuild.exe:

msbuild.exe MySolution.sln /t:Rebuild /p:Configuration=Release /p:NoWarn=0618

但是,这种方法不适用于 MSBuild 警告.也许还有另一个魔法属性要设置?

However, this approach doesn't work for MSBuild warnings. Maybe there is another magic property to set?

我使用的是 .NET 3.5 和 VS2008.

I'm using .NET 3.5 and VS2008.

推荐答案

我已经设法用 /p:WarningLevel=X

msbuild.exe MySolution.sln /t:Rebuild /p:WarningLevel=0 /p:Configuration=Release
                                      ^^^^^^^^^^^^^^^^^
Warning  
Level    Meaning
-------- -------------------------------------------
      0  Turns off emission of all warning messages.

      1  Displays severe warning messages

      2  Displays level 1 warnings plus certain, less-severe warnings, such
         as warnings about hiding class members

      3  Displays level 2 warnings plus certain, less-severe warnings, such 
         as warnings about expressions that always evaluate to true or false

      4  (the default) Displays all level 3 warnings plus informational warnings

这篇关于如何抑制特定的 MSBuild 警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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