有没有办法不让MsBuild用代码契约运行静态契约分析?
在我的项目中,静态检查被禁用,但是当我使用 cmd 运行 msbuild.exe 时,它仍然会开始对每个项目进行静态检查...有没有办法通过参数来禁用此功能?
In my project, static checking is disabled, but still, when I run msbuild.exe with cmd, it starts static checking for each project... Is there a way, with parameters, to disable this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能有点晚了,但因为我刚刚遇到了同样的问题,并且
/p:RunCodeAnalysis=false
对我不起作用:尝试
msbuild ... /p:CodeContractsRunCodeAnalysis =假。
根据 代码契约文档和我的经验。
This might be a 'little' late, but since I just encountered the same problem and
/p:RunCodeAnalysis=false
doesn't work for me:Try
msbuild ... /p:CodeContractsRunCodeAnalysis=false
.That works as of Feb. 2011 according to the code contracts documentation and my experience.
应该执行以下操作:
The following should do it:
如果您不想将参数传递给 msbuild 或者您正在从 Visual Studio 进行构建,则有一种方法可以抑制静态代码契约检查和代码分析。
注意:每个 *.csproj 文件都包含以下内容:
。对于 .Net 4.0 msbuild.exe 和
Microsoft.CSharp.targets
路径为"C:\Windows\Microsoft.NET\Framework\v4.0.30319\"
打开
Microsoft.CSharp.targets
在
Project
中添加新的PropertyGroup
,如下所示:这样做将模拟 msbuild 命令行参数(即
/p:CodeContractsRunCodeAnalysis=false,RunCodeAnalysis=Never,CodeContractsReferenceAssembly=DoNotBuild
现在在你的电脑上的所有构建(无论是来自 MSBuild 还是 Visual Studio)都将跳过代码和静态代码契约分析,因此你不需要从命令行传递参数。
If you don't want to pass parameters to msbuild or you are building from Visual Studio, there is a way to suppress static code contracts check and code analysis.
Notice: each *.csproj file contains this:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
.For .Net 4.0 msbuild.exe and
Microsoft.CSharp.targets
path is"C:\Windows\Microsoft.NET\Framework\v4.0.30319\"
Open
Microsoft.CSharp.targets
Add new
PropertyGroup
insideProject
like:Doing so will emulate msbuild command line arguments (i.e
/p:CodeContractsRunCodeAnalysis=false,RunCodeAnalysis=Never,CodeContractsReferenceAssembly=DoNotBuild
All your builds now on your pc (either from MSBuild and Visual Studio) will skip code and static code contracts analysis, so you don't need to pass args from Command Line.