如何在 MSBuild 12 命令行上指定 TreatWarningsAsErrors

Pil*_*Bob 5 msbuild

我的解决方案中有一个 vb.net 项目,其中包含创建编译器警告的问题。

我已在 Visual Studio 项目设置的编译页面中将“将警告视为错误”设置为 true。

当我在 Visual Studio 2012 中构建调试或发布配置时,我收到错误报告。

当我在 Visual 2013 中构建 Release congif 时,出现错误。当我在调试配置中构建时,我什么也没得到。这似乎是 VS2013 中的一个错误。

当我在命令行(版本 4 或版本 12)中使用 MSBuild 运行时,它只报告警告,无论哪种配置。我尝试了谷歌搜索时发现的各种东西:

msbuild /t:Rebuild /p:TreatWarningsAsErrors="true"
msbuild /t:Rebuild /p:TreatWarningsAsErrors=true
msbuild /t:Rebuild /t:TreatWarningsAsErrors="true"
msbuild /t:Rebuild /t:TreatWarningsAsErrors=true
Run Code Online (Sandbox Code Playgroud)

我尝试过的任何事情都没有透露我想要的结果。我不确定为什么 MSBuild 不使用 .csproj 文件中的设置。

从命令行使用 MBBuild 构建时,将编译器警告视为错误的正确方法是什么?