.net – MSBuild “sgen.exe” is missing

msbuildnetvisual studio 2012windows

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?

Best Answer

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.