title: How to run .NET 4 code analysis on build server
body: <p>On a Windows Server 2003 R2 with .NET 4 SDK but without Visual Studio 2010, I have tried building a Visual Studio 2010 solution with </p>
  
  <pre><code>msbuild MySolution.sln /p:RunCodeAnalysis=true
  </code></pre>
  
  <p>but that fails.</p>
  
  <p>What is required to run code analysis on such an environment?</p>
  
  <hr>
  
  <p>I get this error message:<pre>
  C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(129,9): error MSB6003: 
  The specified task executable "FxCopCmd.exe" could not be run. 
  Could not load file or assembly 
  'Microsoft.VisualStudio.CodeAnalysis.Sdk, Version=10.0.0.0, Culture=neutral, PublicKeyToken= b03f5f7f11d50a3a' 
  or one of its dependencies. 
  The system cannot find the file specified.</pre></p>
  
  <p>I have installed FxCop from the SDK and without luck pointed the variable FxCopDir to the installed location of FxCopCmd.exe, and also setting this registry entry to that location:</p>
  
  <pre><code>HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\10.0\Setup\EDev@FxCopDir
  </code></pre>