如何在命令行中抑制来自msbuild的所有编译器和代码分析警告? [英] how can i suppress all compiler and code analysis warnings from msbuild at the command line?
问题描述
已被问及,但未得到回答.答案(使用/warn:1
)不适用于msbuild.exe,仅适用于csc.exe.也许我在csc和msbuild之间缺少什么?
This has been asked, but wasn't answered. The answer (use /warn:1
) doesn't work for msbuild.exe, only csc.exe. Perhaps I'm missing something between csc and msbuild?
我想禁止所有编译器警告和代码分析警告(例如,分配了变量'variableNameHere',但其值却是..." 或代码分析警告:CA1805: Microsoft.Performance:... ),当我使用命令行msbuild时.我不想更改解决方案文件.我正在构建的大型解决方案中有数百条警告消息-修复这些消息远远超出了我的项目范围.
I'd like to suppress all compiler warnings and code analysis warnings (e.g. "The variable 'variableNameHere' is assigned but its value ..." or Code Analysis Warning : CA1805 : Microsoft.Performance : ...) when I'm using command line msbuild. I don't want to alter the solution file. There are several hundred warning messages in the very large solution that I'm building -- fixing them is far out of scope for my project.
我尝试了/v:quiet
,但是没有用.
I tried /v:quiet
but that didn't work.
是否可以通过命令行执行此操作?
Is there any way to do this via the command line?
更新:此:
C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe C:\Dev\ReallyBigSolution.sln /p:NoWarn=true /p:NoWarn=CA1031
绝对不起作用.我仍然收到数百条警告,包括我专门阻止的警告(CA1031).
Absolutely doesn't work. I still get hundreds of warnings, including the one I specifically blocked (CA1031).
使用/p:RunCodeAnalysis=Never
或/p:RunCodeAnalysis=false
显然不能抑制代码分析警告或错误.
Using /p:RunCodeAnalysis=Never
or /p:RunCodeAnalysis=false
apparently doesn't suppress code analysis warnings or errors.
推荐答案
可以使用编译器上的nowarn 标志,它与.csproj文件中的<NoWarn>
属性相对应.因此,也许msbuild /p:NoWarn="37;68"
将关闭这些警告编号(尚未尝试).
Can use nowarn flag on the compiler, which corresponds to <NoWarn>
property in the .csproj file. So maybe msbuild /p:NoWarn="37;68"
will turn off those warning numbers (haven't tried it).
或使用
http://msdn.microsoft.com/en-us/library/13b90fz7.aspx
完全关闭警告.我不知道该属性的名称,请尝试/p:Warn=0
.
to turn off warnings altogether. I don't know the property name offhand, try /p:Warn=0
.
阅读结尾处的注释;似乎真的不可能摆脱所有这些警告.
read the comments toward the end; seems like really getting rid of all these warnings isn't possible.
这篇关于如何在命令行中抑制来自msbuild的所有编译器和代码分析警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!