MSBuild error MSB3086, with TeamCity

Ben picture Ben · Nov 15, 2011 · Viewed 8.8k times · Source

I am trying to build and deploy a .NET 4 project using MSBuild Web Deploy and TeamCity, I got this working fine (eventually) with an instance of TeamCity running on my local development machine, however when I tried to set up a fresh TeamCity instance with the same settings I got the following error:

\Microsoft.Common.targets(2249, 9): error MSB3086: Task could not find "sgen.exe" 
using the SdkToolsPath 
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\" or the 
registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A".
Make sure the SdkToolsPath is set and the tool exists in the correct processor 
specific location under the SdkToolsPath and that the Microsoft Windows SDK 
is installed 

I'm running Windows Server 2008, and have .NET 4 installed, including (I believe) MSBuild 4. I've also installed Windows SDK 7.1 as other threads suggested this may be the problem, but still no luck. Any ideas or advice would be appreciated.

Thanks

Answer

kevinarpe picture kevinarpe · Jan 8, 2013

I had the same problem with TeamCity. Here are my steps to resolve:

  1. Download Windows SDK for Windows 7.1. If your server/user does not allow Web access, the Web installer won't work, so I recommend the full package download. Be careful to download the correct version -- x86 [32-bit], x64 [64-bit], or Itanium.
  2. During installation, you only need to select one option: .NET Development -> Tools enter image description here
  3. Try the build again. I did not need to restart my agent for the build to work correctly.

If you accept the default paths for installation, sgen.exe will be found here:

C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\sgen.exe