…meie igapäevast IT’d anna meile igapäev…

2008-02-05

Task failed because "sgen.exe" was not found: solution

Filed under: Programmeerimine — Sander @ 11:16:04

VisualStudioLogo 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.

This is a f*ck-up of Microsoft Visual Studio 2008 when project has web references. It may or may not occur only when VS 2008 beta version was previously installed to the machine – or it may be related to creating .NET 2.0 project in VS 2008. Changing the registry key will not help nor will adding C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\ to the path. I did not try other solutions.

This issue has been also brought up at http://danhounshell.com/blogs/dan/archive/2006/08/22/1140.aspx, http://dhvik.blogspot.com/2007/11/task-failed-because-was-not-found.html and elsewhere, but there was no working fix. However, I used FileMon to check what Visual Studio is looking for – and it appears that it will always look for that file at C:\WINDOWS\Microsoft.NET\Framework\v3.5\, which is does not contain sgen.exe.

Just copy sgen.exe from C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\ to C:\WINDOWS\Microsoft.NET\Framework\v3.5\ and everything will now compile just fine. Here, to make your life easier, copy command:

copy /y “C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sgen.exe”  “C:\WINDOWS\Microsoft.NET\Framework\v3.5\”

Good luck!

About these ads

30 kommentaari »

  1. Thanks so much for the explanation and simple cut & paste command.

    kommentaar kirjutas Jon — 2008-02-05 @ 18:32:40 | Vasta

  2. Thanks!
    By the way, it happened to me, and i never installed any of the betas.

    kommentaar kirjutas Miguel — 2008-02-13 @ 10:53:12 | Vasta

  3. sgen.exe – The “XML Serializer Generator Tool” (why isn’t it xmlsgen.exe?) – is normally distributed with .NET Framework (why normally?)

    The location of sgen.exe is supposedly specified by a macro (AKA Environment Variable) SGenToolPath which is used within Microsoft.Common.Targets (Commonly found at C:\Windows\Microsoft.NET\Framework\%VERSION_STRING%)

    Attempts to find where this Macro is defined have failed on my installation, as a result an incorrect default location appears to be used . (Did I mention I don’t use the brain-dead single gigantic C: partition, and so install software to a ‘user’ partition which I denominate as the ‘U:’ drive)

    What I did instead was to replace the (idiotically) hardcoded path to sgen within the post-build step (Project->Properties->Build Events) with this “$(FrameworkSDKDir)\Bin\sgen” /nologo /force $(TargetFileName).

    Works fine. and doesn’t require you to copy files around (ALWAYS A BAD IDEA !!!)

    kommentaar kirjutas Jack Smith — 2008-03-13 @ 13:19:19 | Vasta

  4. Well, it worked when I needed a quick answer. Thank you very much!

    kommentaar kirjutas Antonio — 2008-05-06 @ 15:34:26 | Vasta

  5. That worked a treat, thanks!

    :)

    A

    kommentaar kirjutas Andrew Beaton — 2008-05-20 @ 16:32:40 | Vasta

  6. thanks heaps!!!

    kommentaar kirjutas kelly — 2008-07-03 @ 05:37:34 | Vasta

  7. Thanks for the info. In my case I had only downloaded Visual Studio 2008 express with no previous VS or framework installs. sgen.exe did not exist anywhere. To get it, download and install the .Net 2.0 SDK. Then do as suggested here.

    kommentaar kirjutas Jacq Inabox — 2008-09-25 @ 15:53:06 | Vasta

  8. Than you very much!!

    kommentaar kirjutas Ersin — 2008-11-06 @ 13:11:08 | Vasta

  9. Worked like a charm! I came across the problem when i was working on a new machine with no prior VS installs.

    Thanks!

    kommentaar kirjutas Rik de Vreede — 2008-11-18 @ 09:50:56 | Vasta

  10. Thank you! Bloody microsoft!!! :-p

    kommentaar kirjutas Stephen — 2008-12-10 @ 08:16:08 | Vasta

  11. Thanks buddy.. Great Tip!!!

    kommentaar kirjutas vineeth — 2009-02-02 @ 22:47:07 | Vasta

  12. Hi

    Thanks a billion . you saved my day. :)

    kommentaar kirjutas Joe — 2009-04-24 @ 17:32:02 | Vasta

  13. You saved my day. THANK YOU

    kommentaar kirjutas Priyanga — 2009-06-11 @ 08:06:38 | Vasta

  14. Thank you!

    kommentaar kirjutas Marco Pankow — 2009-08-27 @ 10:47:48 | Vasta

  15. Extremely useful post.

    kommentaar kirjutas Doug Kirschman — 2009-09-22 @ 23:49:24 | Vasta

  16. It worked!!! Many thanks

    kommentaar kirjutas Miguel — 2009-12-29 @ 14:55:41 | Vasta

  17. thanks! Simple Copy.

    kommentaar kirjutas Guy — 2010-02-09 @ 19:18:37 | Vasta

  18. Thank you.

    kommentaar kirjutas Greg — 2010-02-18 @ 18:59:28 | Vasta

  19. Thanks! This saved me a ton of time. I even ran a search for the file and didn’t find it. didn’t think about looking in the bin directory.

    kommentaar kirjutas Joe — 2010-03-01 @ 05:26:25 | Vasta

  20. I know it’s a long time after this issue has come up, but here’s how I fixed it. Open up the project settings. Go to the “Build” tab on the left. Select “All Configurations” from the “Configuration” drop down. In the “Generate Serialization Assembly” select “Off”. That did it for me. Not sure why it defaults to thinking that a serialization assembly needs to be created for a release build but not a debug build. Anyway, good luck.

    kommentaar kirjutas Anson — 2010-03-14 @ 05:27:50 | Vasta

  21. Funciono perfecto, muchas gracias!
    It worked fine, thanks!!

    kommentaar kirjutas Pablo — 2010-04-08 @ 21:13:36 | Vasta

  22. If you would like to keep the webservices then this is a straight forward solution. Check out the link here: http://www.itjungles.com/dotnet/task-failed-because-sgen-exe-was-not-found-solution

    kommentaar kirjutas Ben — 2010-04-23 @ 10:23:29 | Vasta

  23. thanks! you save my time on this “sgen.exe” problem!

    kommentaar kirjutas Du — 2010-08-09 @ 14:13:54 | Vasta

  24. Solution from #22 post worked for me. Thanks.

    kommentaar kirjutas Laltu — 2010-12-29 @ 05:23:00 | Vasta

  25. On x64 I did copy sgen.exe from C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\ to C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\Bin\ and that did the trick – I’m using VSTO with infopath 2010 I did receive that error before also.

    kommentaar kirjutas obp — 2011-03-28 @ 08:39:59 | Vasta

    • Thank you for this! Using InfoPath, and added the exe to all the other paths recommended, but this one did it. Thanks!!

      kommentaar kirjutas TS — 2012-06-07 @ 23:59:40 | Vasta

  26. [...] You will want to click the “Upgrade OM” button which will prompt you to verify that you are sure you want to do this. Click “Yes”. For this to operate successfully you will need to have the .Net 2.0 framework installed or following this registry hack and do some file copying)http://dukelupus.wordpress.com/2008/02/05/task-failed-because-sgenexe-was-not-found-solution/ [...]

    Pingback-viide kirjutas Upgrade InfoPath 2007 to 2010 | TCSC Blog — 2011-09-05 @ 22:22:19 | Vasta

  27. @anson (number 20) – thank you for posting your solution – it worked a treat.

    kommentaar kirjutas Kelli Dudley — 2012-05-30 @ 18:59:46 | Vasta

  28. [...] This seem to be a known problem with some discussion here http://dukelupus.wordpress.com/2008/02/05/task-failed-because-sgenexe-was-not-found-solution/ [...]

    Pingback-viide kirjutas deploying web reference to azure websites - Windows Azure Blog — 2012-08-20 @ 22:25:26 | Vasta

  29. Thanks so much. It worked perfectly!

    kommentaar kirjutas Ricardo — 2013-02-18 @ 19:31:59 | Vasta


Selle postituse kommentaaride RSS-voog. TrackBack URI

Lisa kommentaar

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Muuda )

Twitter picture

You are commenting using your Twitter account. Log Out / Muuda )

Facebook photo

You are commenting using your Facebook account. Log Out / Muuda )

Google+ photo

You are commenting using your Google+ account. Log Out / Muuda )

Connecting to %s

Theme: Rubric. Get a free blog at WordPress.com

Follow

Get every new post delivered to your Inbox.

Join 81 other followers