And*_*rew 92 msbuild command-line
从命令行运行MSBuild时,有没有办法禁用特定的MSBuild警告(例如MSB3253)?我的构建脚本以下列方式调用msbuild.exe:
msbuild.exe MySolution.sln /t:Rebuild /p:Configuration=Release
Run Code Online (Sandbox Code Playgroud)
我发现我可以使用msbuild.exe的另一个参数来抑制C#警告(例如CS0618):
msbuild.exe MySolution.sln /t:Rebuild /p:Configuration=Release /p:NoWarn=0618
Run Code Online (Sandbox Code Playgroud)
但是,此方法不适用于MSBuild警告.也许还有另一个魔法属性可以设定?
我正在使用.NET 3.5和VS2008.
小智 53
我设法压制了警告级别 /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
Run Code Online (Sandbox Code Playgroud)
Sta*_*kov 31
对于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>
Run Code Online (Sandbox Code Playgroud)
较新版本的 MSBuild 通过命令行(如 EM0 所述)或属性支持此功能:
<PropertyGroup>
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);MSB3253</MSBuildWarningsAsMessages>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅此评论。
我没有找到关于此的官方文档,但在VerifyFileHash任务文档中提到了它。
替代方法:将此添加到 .csproj。
<PropertyGroup>
<NoWarn>$(NoWarn);MSB3253</NoWarn>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
44775 次 |
| 最近记录: |