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?

Signing a ClickOnce manifest file using a spc/pvk certificate

To sign a ClickOnce manifest file/assembly you need a pfx file without chaining information.

First we need to convert the spc/pvk file to a pfx file. As Stuart found out you use the pvk2pfx tool to accomplish this.

If we try to use this certificate and it contains chaining information we will get an error stating

"Cannot find the certificate and private key for decryption"

Then we need to make sure that the pfx don't include the chaining information as described in the case @ commodo (importing and exporting the pfx).

When these steps has been completed, you can build and sign your application.