TeamCity Release Build sgen.exe gotcha

TeamCity is great, I had it up and running with Automated Tests in just minutes. But.. attempting to make a Release Build generated the following error. Googling shows many people have the same error and I only found ugly solutions that required manual registry editing, copying of files etc:

c:WINDOWSMicrosoft.NETFrameworkv3.5Microsoft.Common.targets(2015, 9): error MSB3091: Task failed because “sgen.exe” was not found, or the correct Microsoft Windows SDK is not installed. The task is looking for “sgen.exe” in the “bin” subdirectory beneath the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SDKsWindowsv6.0A. You may be able to solve the problem by doing one of the following: 1) Install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5. 2) Install Visual Studio 2008. 3) Manually set the above registry key to the correct location. 4) Pass the correct location into the “ToolPath” parameter of the task.

The first thing I did was use msbuild from the command line; sure enough Debug Builds were fine and Release Builds had the same error. This ruled out Team City. Obviously installing VS2008 on our build box would solve the issue, but I assumed the build tools must available elsewhere without need all of VS2008. They are:

The solution is: Download the Windows SDK and install .Net Development Tools (it says 2008 Server but I did this on XP SP3).

This entry was posted in Uncategorized. Bookmark the permalink.