MSBuild error MSB3086, with TeamCity
Asked Answered
A

4

7

I am trying to build and deploy a .NET 4 project using MSBuild Web Deploy and TeamCity, I got this working fine (eventually) with an instance of TeamCity running on my local development machine, however when I tried to set up a fresh TeamCity instance with the same settings I got the following error:

\Microsoft.Common.targets(2249, 9): error MSB3086: Task could not find "sgen.exe" 
using the SdkToolsPath 
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\" or the 
registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A".
Make sure the SdkToolsPath is set and the tool exists in the correct processor 
specific location under the SdkToolsPath and that the Microsoft Windows SDK 
is installed 

I'm running Windows Server 2008, and have .NET 4 installed, including (I believe) MSBuild 4. I've also installed Windows SDK 7.1 as other threads suggested this may be the problem, but still no luck. Any ideas or advice would be appreciated.

Thanks

Audette answered 15/11, 2011 at 17:21 Comment(1)
I know you've mentioned it, but it is a SDK path problem.Finnougric
E
6

There is/was something wonky about the way the windows SDK 7.0A installs with verus without visual studio. There are pathing issues. Easy way out is to install Visual Studio on the build machine, but that feels wrong. Or at least it does to me. Another option is to set your builds not to create the serialization assemblies -- they don't matter in many cases. Note that if you skip release builds this happens by default.

Real fix is to properly point TeamCity at sgen.exe and then tell msbuild to use the right folder by using the right toolspath. See this question for a good explanation.

Elidaelidad answered 15/11, 2011 at 17:28 Comment(6)
Thanks for the response, I agree installing VS on a build server seems massively wrong, but It looks like I may have to. I followed the advice in #2749474 and set the SdkToolsPath registry key, but got the same error, and turned serialisation off, same error again. I the weird thing is it's still looking for 7.0A but i've set the current version to 7.1. I may just have to install VS :-( any other advice would be appreciated.Audette
@RitchMelton : why? part of the point of a build server is to make sure I can build this without the help of thick development tools.Elidaelidad
@Wyatt - I've never considered building without 'thick development tools' a goal of CI, but installing VS alleviates quite a few problems like the the OP's. The problem with putting it on the server is that it consumes a license and you really shouldn't have to do it that way.Finnougric
@RitchMelton : exactly -- you shouldn't need the editor to build the artifacts. Moreover, you really should understand how to build it without the tools, depending on black magic is bad.Elidaelidad
I really hate the idea of installing VS on a build server, but then again I've been messing around in the registry, installing SDKs, changing build configurations and trying to change default SDKs all of which I didn't like doing and didn't work, so I've installed VS, and it works ... it doesn't mean I like it though :p Thanks for all the help :-)Audette
@wyatt - Good lord. Infer much?Finnougric
P
7

I had the same problem with TeamCity. Here are my steps to resolve:

  1. Download Windows SDK for Windows 7.1. If your server/user does not allow Web access, the Web installer won't work, so I recommend the full package download. Be careful to download the correct version -- x86 [32-bit], x64 [64-bit], or Itanium.
  2. During installation, you only need to select one option: .NET Development -> Tools enter image description here
  3. Try the build again. I did not need to restart my agent for the build to work correctly.

If you accept the default paths for installation, sgen.exe will be found here:

C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\sgen.exe
Payola answered 8/1, 2013 at 4:37 Comment(0)
E
6

There is/was something wonky about the way the windows SDK 7.0A installs with verus without visual studio. There are pathing issues. Easy way out is to install Visual Studio on the build machine, but that feels wrong. Or at least it does to me. Another option is to set your builds not to create the serialization assemblies -- they don't matter in many cases. Note that if you skip release builds this happens by default.

Real fix is to properly point TeamCity at sgen.exe and then tell msbuild to use the right folder by using the right toolspath. See this question for a good explanation.

Elidaelidad answered 15/11, 2011 at 17:28 Comment(6)
Thanks for the response, I agree installing VS on a build server seems massively wrong, but It looks like I may have to. I followed the advice in #2749474 and set the SdkToolsPath registry key, but got the same error, and turned serialisation off, same error again. I the weird thing is it's still looking for 7.0A but i've set the current version to 7.1. I may just have to install VS :-( any other advice would be appreciated.Audette
@RitchMelton : why? part of the point of a build server is to make sure I can build this without the help of thick development tools.Elidaelidad
@Wyatt - I've never considered building without 'thick development tools' a goal of CI, but installing VS alleviates quite a few problems like the the OP's. The problem with putting it on the server is that it consumes a license and you really shouldn't have to do it that way.Finnougric
@RitchMelton : exactly -- you shouldn't need the editor to build the artifacts. Moreover, you really should understand how to build it without the tools, depending on black magic is bad.Elidaelidad
I really hate the idea of installing VS on a build server, but then again I've been messing around in the registry, installing SDKs, changing build configurations and trying to change default SDKs all of which I didn't like doing and didn't work, so I've installed VS, and it works ... it doesn't mean I like it though :p Thanks for all the help :-)Audette
@wyatt - Good lord. Infer much?Finnougric
N
4

I banged my head on this for a full 8 hours, gave up, and figured it out in 30 minutes the next morning. I have tried everything I could find on the interwebs. Here is how i figured it out. I already confirmed that i have sdk 7.1, 7.0 installed on my build agent. Ultimately it came back to registry settings.

First for MSBUILD Under "HKEY_LOCAL_MACHINE\SOFTWARE\MSBUILD\ToolsVersions\4.0". The Key SDK40toolsPath value is $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools-x86@InstallationFolder) on my build agent.

Which references "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools-x86@InstallationFolder". However, on my build agent that registry didn't exist! So it was referencing NOTHING. I don't know how the 7.0A registry setting are supposed to get there?!

So, I exported the entire "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" registry from a working build agent to a file then copied and imported it to the broken agent. It finally works now. Hope this helps someone.

This is probably over kill but here is the exported registry file contents.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\"
"ProductVersion"="7.1.7600.0.30514"
"ProductName"="Microsoft Windows SDK for Windows 7 (7.1.7600.0.30514)"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools]
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Tools for .NET Framework 4.0"
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Bin\\NETFX 4.0 Tools\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools-x64]
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Tools for .NET Framework 4.0 (x64)"
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Bin\\NETFX 4.0         Tools\\x64\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools-x86]
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Tools for .NET Framework 4.0"
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Bin\\NETFX 4.0 Tools\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKBuild]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Microsoft Windows SDK Headers and Libraries"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKIntellisenseNFX]
"InstallationFolder"="C:\\Windows\\Microsoft.NET\\Framework\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Microsoft Windows SDK Intellisense for .Net"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKIntellisenseRefAssys]
"InstallationFolder"="C:\\Program Files\\Reference Assemblies\\Microsoft\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Intellisense and Reference Assemblies"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKInterop]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Microsoft Windows SDK NetFx Interop"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKNetFx35Tools]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Microsoft Windows SDK NetFx 3.5 Tools"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKNetFx35Tools\1033]
"SP"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKNetFx35Tools-x64]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\x64\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Microsoft Windows SDK NetFx 3.5 Tools (x64)"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKSamples]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Samples\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Samples"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKTools]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Common Utilities"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKTools-x64]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\x64\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Common Utilities (x64)"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKWin32Tools]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Utilities for Win32 Development"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDKWin32Tools-x64]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\x64\\"
"ProductVersion"="7.1.7600.0.30514"
"ComponentName"="Windows SDK Utilities for Win32 Development (x64)"}
Neff answered 15/8, 2012 at 15:19 Comment(1)
Thanks for sharing, I ended up installing VS, nasty but it worked. If I come against this again I will definitely try and follow your advice.Audette
L
0

In my case, the issue arose when I added a Web Reference (C# 2.0) to my project. I was able to get around it by building the proxy manually.

wsdl.exe /out:d:\dev\MyProxy.cs /order https://blahblahblah?wsdl

...then just copying MyProxy.cs into my project, instead.

Lorica answered 3/5, 2016 at 18:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.