从命令行运行 MSBuild 时,有什么方法可以禁用特定的 MSBuild 警告(例如 MSB3253)?我的构建脚本通过以下方式调用 msbuild.exe:
msbuild.exe MySolution.sln /t:Rebuild /p:Configuration=Release
我发现我可以使用 msbuild.exe 的另一个参数来抑制 C# 警告(例如 CS0618):
msbuild.exe MySolution.sln /t:Rebuild /p:Configuration=Release /p:NoWarn=0618
但是,此方法不适用于 MSBuild 警告。也许还有另一个魔法属性要设置?
我正在使用 .NET 3.5 和 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
关于command-line - 如何抑制特定的 MSBuild 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1023858/