Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild "sgen.exe" is missing

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?

like image 990
John Paul Avatar asked Dec 02 '15 14:12

John Paul


3 Answers

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.

like image 80
John Paul Avatar answered Sep 29 '22 11:09

John Paul


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.

like image 27
Liz Ọwọadé Avatar answered Sep 29 '22 11:09

Liz Ọwọadé


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.

like image 20
user9291046 Avatar answered Sep 29 '22 10:09

user9291046