2007-11-26

Task failed because "sgen.exe" was not found

I installed Visual Studio 2008 (final) and started to create a WinForms (2.0) application that calls a webservice and is deployed with clickonce. When I try to compile it (after adding the webreference) I get the following build error

C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(1993,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_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.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.


I thought that the SDK was to be installed with VisualStudio 2008, but when looking into the SDKs folder (C:\Program Files\Microsoft Visual Studio 9.0\SDK) it contains almost nothing, only a few files in the v3.5 folder.

When I searched for the SDK for framework 3.5 it seems that is included in the windows server 2008 platform sdk and that is only avaliable for beta2 so far...

Regarding the registry settings, I have the SDK for v2.0 installed and since I build vs the 2.0 framework, shouldn't it look in the KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v2.0 key?

How do I set the ToolPath?

Anyway, I came around the issue by setting the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A InstallationFolder key to the same path as the 2.0 Sdk path and compilation was successful...

Is the VisualStudio 2008 release not final since it seems to miss the SDK or have I been sloppy installing the product?

10 comments:

  1. I have exactly the same problem. Possibly I did not uninstall VS 2008 Beta 2 correctly or it left some traces which suppress the installation of SDK V6.0A. Repairing VS2008 does not help. Is there any way to force the installation of SDK V6.0A?

    ReplyDelete
  2. Not that I know of. I started a forum thread @ microsoft to get a formal response on this issue.

    ReplyDelete
  3. Same problem directory C:\Program Files\Microsoft Visual Studio 9.0\SDK\v3.5\Bin does not contain files (gacutil.exe, sn.exe etc ...)

    ReplyDelete
  4. Beta, shmaita, I just had this problem with the VS 2008 RTM. Adding the "InstallationFolder" value under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A and rebooting solved the problem.

    ReplyDelete
  5. The following links give more information on the problem, its cause, and solution.

    http://forums.asp.net/p/1293282/2513461.aspx

    http://dhvik.blogspot.com/2007/11/task-failed-because-was-not-found.html

    http://iformattable.blogspot.com/2008/01/tfs-build-failure-msbuild-tool-missing.html

    ReplyDelete
  6. i copied sgen.exe from other machine to
    C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin
    added new registry key to
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows
    with name "v6.0A"
    and added new string value "installationfolder" with value data as "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0"

    ReplyDelete
  7. Hi ..
    Copy the SDK folder to
    C:\Program Files\Microsoft Visual Studio 8
    copy the sgen.exe from
    C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin to
    C:\Windows\Microsoft.NET\Framework\v3.5


    RG4444

    ReplyDelete
  8. I had this problem too with TFS 2010 x64. Tried everything without solution.

    In registry there was HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0 key

    But not

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A key

    Naturally the directories were missing too.

    I exported the key from my workstation which had visual studio installed and imported it on the server. I then copied sgen.exe file to directories mentioned in string values under that key.

    ReplyDelete
  9. Much Appreciated!!!! This did the trick!

    ReplyDelete
  10. Ans :Please go to that below address and do that step while installing SDK....
    Download the Windows SDK(http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=e6e1c3df-a74f-4207-8586-711ebe331cdc) and install .Net Development Tools (it says 2008 Server but I did this on XP SP3):

    http://dotnetworkaholic.com/2009/06/17/teamcity-release-build-sgen-exe-gotcha/#comment-445

    ReplyDelete