有没有什么办法来禁用特定的MSBuild警告(例如MSB3253)从命令行运行的MSBuild是什么时候? 我的构建脚本调用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
根据此线程在MSDN论坛的MSBuild警告不能被抑制。
对于MSB3253您可以在项目文件(* .csproj的)导致这样的警告只是设置。
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<!-- some code goes here -->
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
None
</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<!-- some code goes here -->
</PropertyGroup>
对于那些现在谷歌搜索这(和我一样):即将到来的MSBuild 15.0将最终(与Visual Studio的2017年,我相信发布) 执行/NoWarn
选项来抑制特定的警告(以及/WarnAsError
治疗或者特定的警告或全部警告视为错误)。