gpt4 book ai didi

visual-studio-2010 - MSBuild:将单个警告视为错误

转载 作者:行者123 更新时间:2023-12-03 21:38:27 25 4
gpt4 key购买 nike

有没有办法强制 MSBuild 将特定警告视为错误?

运行 ccproj 文件的发布目标以创建 cspkg 以部署到 Azure 时,会引发以下错误:

Project.Name : warning WAT150: The project 'Project.Name' is dependent on the following assembly: C:\Windows\assembly\GAC_64\DllName\2.10.0.0__Guid\DllName.dll. This assembly is not in the package. To make sure that the role starts, add this assembly as a reference to the project and set the Copy Local property to true. [C:\bld\66\797\Sources\Applications\cloud\Project.Name.ccproj]

这是一个警告,可能意味着角色在部署时不会启动...我想让 WAT150 成为一个错误。 有没有办法使特定的单个警告或警告列表成为错误?

最佳答案

在 MSBuild 中,您可以使用 /warnaserror命令行开关

  /warnaserror[:code[;code2]]
List of warning codes to treats as errors. Use a semicolon
or a comma to separate multiple warning codes. To treat all
warnings as errors use the switch with no values.
(Short form: /err[:c;[c2]])

Example:
/warnaserror:MSB4130

When a warning is treated as an error the target will
continue to execute as if it was a warning but the overall
build will fail.

这相当于设置<WarningsAsErrors>项目文件中的属性 ( docs )。

为了完整起见,C# 编译器还具有 -warnaserror命令行选项( docs )。

关于visual-studio-2010 - MSBuild:将单个警告视为错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15552055/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com