11

I'm getting the following error when using MSBuild. The error I am getting is:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2769,5): error MSB3086: Task could not find "sgen.exe" using the SdkToolsPath "" or the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8. 0A\WinSDK-NetFx40Tools-x86". Make sure the SdkToolsPath is set and the tool exi sts in the correct processor specific location under the SdkToolsPath and that the Microsoft Windows SDK is installed

So far I have done the following:

1) Install Windows SDK v8 from here

2) I confirmed that the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8. 0A\WinSDK-NetFx40Tools-x86" exists in the registry

3) The registry key from 2 above points to the path "C:\Program Files\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools" and I have confirmed that the path exists and that sgen.exe is located in that directory

4) I have also did some of my own research and came across this SO post but the answer involves installing visual studio on the server itself which is NOT an option for me. However I do want to point out that I have another build server with the exact same setup and it's working fine so my temporary work around is to build it on that server and then copy the build over.

Anyone have any insight on what the problem might be?

Community
  • 1
  • 1
John Paul
  • 827
  • 2
  • 6
  • 16

3 Answers3

9

I was finally able to resolve it. Steps to resolution:

1) Uninstall windows sdk 8 via Program and Features.

2) Install windows sdk 8.1 from here.

3) Edit the registry keys

  • SDK40ToolsPath
  • SDK35ToolsPath

under

HKLM\SOFTWARE\Wow6432Node\MSBuild\ToolsVersions\11.0

to

$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1A\WinSDK-NetFx40Tools-x86@InstallationFolder)

and the registery keys

  • FrameworkSDKRoot
  • WindowsSDK80Path

to

$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1@InstallationFolder)

Hope this might help someone else in the future if they run into the same problem.

John Paul
  • 827
  • 2
  • 6
  • 16
  • 1
    Thanks John Paul. On my machine, this was under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\4.0\11.0, HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\14.0\11.0, and HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\14.0\14.0 and I set the SDK40ToolsPath to C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools on all of them. – TomEberhard May 17 '16 at 22:56
  • I just copy the \toolsversions\4.0\ key values to \toolsversions\4.0\11.0, but this answer clarify the problem for me... tks – Claudio Santos Jun 17 '16 at 12:04
  • I haven't found the registry path suggested, but found an alternative path that appears to have the same expected values, but in v12 folder, not v11. Is this the same thing? Was it a typo? HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\MSBuild\ToolsVersions\12.0\11.0 – Will Strohl Aug 19 '17 at 19:01
4

This answer didn't work for me. I already had the Windows 8.1 SDK but not the version 8. I had to download version 8 which contained the .Net Framework 4.5 SDK. The .Net Framework 4.5 SDK (comes with Windows 8 SDK) and 4.6 SDK (comes with Visual Studio 2015). I have VS 2015.

All the SDKs can be individually downloaded at https://msdn.microsoft.com/en-us/library/5a4x27ek(v=vs.110).aspx.

I downloaded the 4.5 SDK and installed it (note without the Application Verifier feature as that causes an installation error). After a reboot, my build worked fine.

  • 1
    I gave up with SDK 10. It is kind 8.1 SDK and others were ignored after 10 SDK. But thanks, you give me a hope) I have solved this issue by a cmd wrapper http://stackoverflow.com/a/41784486/390940 – it3xl Jan 21 '17 at 23:09
2

I had the same error, sgen.exe is missing while using MSBuild. I did not have to change the registry values. I made sure the MSBuild command was using the version I had installed. I had Visual Studio 2015 and 2017 installed on my PC.

In my case it was C:\Program Files (x86)\MSBuild\14.0\bin. So I set the path to this value, and when I ran my batch file with the new path set, it compiled successfully.

Zze
  • 18,229
  • 13
  • 85
  • 118