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

2008-02-05

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

Rubriigid: Programmeerimine — dukelupus @ 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!

13 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


Selle postituse kommentaaride RSS-voog. TrackBack URI

Lisa kommentaar

Blog at WordPress.com.