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!
RSS Feed
Thanks so much for the explanation and simple cut & paste command.
Comment kirjutas Jon — 2008-02-05 @ 18:32:40 |
Thanks!
By the way, it happened to me, and i never installed any of the betas.
Comment kirjutas Miguel — 2008-02-13 @ 10:53:12 |
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 !!!)
Comment kirjutas Jack Smith — 2008-03-13 @ 13:19:19 |
Well, it worked when I needed a quick answer. Thank you very much!
Comment kirjutas Antonio — 2008-05-06 @ 15:34:26 |
That worked a treat, thanks!
:)
A
Comment kirjutas Andrew Beaton — 2008-05-20 @ 16:32:40 |
thanks heaps!!!
Comment kirjutas kelly — 2008-07-03 @ 05:37:34 |
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.
Comment kirjutas Jacq Inabox — 2008-09-25 @ 15:53:06 |
Than you very much!!
Comment kirjutas Ersin — 2008-11-06 @ 13:11:08 |
Worked like a charm! I came across the problem when i was working on a new machine with no prior VS installs.
Thanks!
Comment kirjutas Rik de Vreede — 2008-11-18 @ 09:50:56 |
Thank you! Bloody microsoft!!! :-p
Comment kirjutas Stephen — 2008-12-10 @ 08:16:08 |
Thanks buddy.. Great Tip!!!
Comment kirjutas vineeth — 2009-02-02 @ 22:47:07 |
Hi
Thanks a billion . you saved my day. :)
Comment kirjutas Joe — 2009-04-24 @ 17:32:02 |
You saved my day. THANK YOU
Comment kirjutas Priyanga — 2009-06-11 @ 08:06:38 |
Thank you!
Comment kirjutas Marco Pankow — 2009-08-27 @ 10:47:48 |
Extremely useful post.
Comment kirjutas Doug Kirschman — 2009-09-22 @ 23:49:24 |