command-line - 如何抑制特定的 MSBuild 警告

标签 command-line msbuild

从命令行运行 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/

相关文章:

msbuild - SonarQube MSBuild-Runner 使用项目文件中的自定义 FXCop 规则

msbuild - 如何在 MSBuild 中连接文件并保留制表符和空格

c# - "AssemblyInfo"MSBuild 任务在 Jenkins 构建中失败

python - 如何避免在处理 KeyboardInterrupt 后打印 ^C

command-line - ffmpeg 部分转码使用 -ss 和 -to

python - 编写一个脚本将文件上传到 iRODS,我是否用 Python 编写并合并 iRODS 命令?

c# - NuGet:如何在 nuget pack 期间指定许可证 URL?

visual-studio-2008 - MSBuild 覆盖项目引用以解析为预编译程序集

c++ - Mac 独立 Xcode c++ 命令行项目

unit-testing - Codeception - 验收测试有效,但功能测试无效