6

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?

Lieven Cardoen
  • 25,140
  • 52
  • 153
  • 244

3 Answers3

8

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.

mnemosyn
  • 45,391
  • 6
  • 76
  • 82
2

The following should do it:

MSBuild ... /p:RunCodeAnalysis=false
Ade Miller
  • 13,575
  • 1
  • 42
  • 75
1

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 inside Project like:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
 <PropertyGroup>  
   <CodeContractsRunCodeAnalysis>false</CodeContractsRunCodeAnalysis>
   <RunCodeAnalysis>Never</RunCodeAnalysis>
   <CodeContractsReferenceAssembly>DoNotBuild</CodeContractsReferenceAssembly>
 </PropertyGroup>
...
<!-- a lot of stuff -->
...
</Project>

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.

Gleb Sevruk
  • 494
  • 5
  • 9