tags:

views:

2619

answers:

10

Howdy, I'm having a bit of an issue runnning a NAnt script that used to properly build my .Net 2.0 based website, when compiling with VS2008 and it's associated tools. I've recently upgraded all the project/solution files to VS2010, and now my build fails with the following error:

[exec] C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(2249,9): error MSB3086: Task could not find "sgen.exe" using the S dkToolsPath "" 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

Now, I DO have prior versions (.Net 3.5) of the Windows SDK installed on the build server, and the full .Net 4.0 framework is installed, but I've not run across a .Net 4.0 specific version of the Windows SDK.

After a bit of experimentation and research, I finally just setup a new environmental variable "SDKToolsPath" and pointed it to the copy of sgen.exe in my windows 6.0 sdk folder. This generated the same error, but it got me to notice that even though the SDKToolsPath environmental variable IS set (confirmed that I can "echo" it at the command line and it has the expected value), the error message seems to indicated that it's not being read (note the empty quotes).

Most of the information I've found is .Net 3.5 (or earlier) specific. Not much 4.0 related out there yet. Searching for error code MSB3086 generated nothing useful either. Any idea what this might be?

Scott

A: 

I suspect the targets file is overriding the tools path, I had a quick look in this file and is sets the SDKToolsPath to $TargetFrameworkSDKToolsDirectory under some of the targets in there. I don't think you should need to set these in the environment anyway, but they may need fixing in your project files.

Note that according to this page http://nant.sourceforge.net/ Nant does not support .Net 4.0, could this be the real problem?

Sorry, I know this doesn't really answer your question:(

Steve Haigh
Correct, NAnt doesn't support the project/solution file formats for VS2010 yet, which is why I'm calling out to MSBuild for the actual compilation step. Will check out the targets file.
Scott Mayfield
+1  A: 

You don't actually have SDK version 7.0A installed? That's a problem you'll need to fix. Look in the VS2010 install log files to see what went wrong. The SDK should be present in c:\program files\microsoft sdks\windows\7.0a and the listed registry key must be present as well. Running with the 6.0a version of sgen.exe isn't okay, it is bound to use the wrong compiler.

Hans Passant
Remember, this is a build server, so installing the complete VS2010 environment wasn't my first choice. I was unable to find any available download of the Windows SDK 7.0a
Scott Mayfield
I don't see the problem. Running a build on a machine who's configuration doesn't match the dev machines, that's a problem that will wear you out quickly.
Hans Passant
+2  A: 

I had to bite the bullet and install VS 2010 on our build server to fix this issue. As far as I can see, there's no 7.0A version of the Windows SDK available anywhere on MSDN. However, installing VS 2010 appears to install it, creating a 7.0A regkey and a 7.0A folder in Program Files\Microsoft SDKs\Windows.

John Hann
Yes, I eventually did that as well and it solved my issue. But I'm not thrilled about having the entire VS2010 environment on my build server when it seems that there should simply be a downloadable version of the 7.0a Windows SDK. Would love to know the URL if anyone has it available.
Scott Mayfield
abatishchev
Yes, but it is not Version 7.0a, and that is important here. There's an interesting workaround posted here, haven't tried it myself though: http://stackoverflow.com/questions/1109955/task-failed-because-al-exe-was-not-found/2758894#2758894
John Hann
I prefer not to install Visual Studio 2010 on a server. I prefer Simmo's suggestion below of setting the current Windows SDK to v7.1. WindowsSdkVer.exe is located in C:\Program Files\Microsoft SDKs\Windows\v7.1\Setup (assuming it was installed to C:\Program Files).
Philippe
A: 

Related issue in this post. I posted an answer there as well. http://stackoverflow.com/questions/1109955/task-failed-because-al-exe-was-not-found/2758894#2758894

Diego C.
+21  A: 

I couldn't face putting Visual Studio on the build server.

The SDK v7.0A is the SDK installed with Visual Studio 2010 (The A indicates this is a VS release). Since then, a newer version has been released. Microsoft Windows SDK for Windows 7 and .NET Framework AKA v7.1.

I've installed this on my build server. And then via the Windows SDK 7.1 Command Prompt (Start => All Programs => Microsoft Windows SDK 7.1), I set the default version of the SDK to be 7.1.

Steps:

cd Setup

WindowsSdkVer.exe -version:v7.1
Simmo
This worked perfectly for me, combined with copying across the files into C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications from my VS machine.
dnolan
Thanks so much for this answer!
Dan Fitch
I was facing the same problem as the original author and this answer solved it! I did not have to install Visual Studio 2010 on my Build machine.
SolutionYogi
Also, just to clarify, one doesn't need to install the entire SDK. Installing just the ".NET Development/Intellisense and Reference Assemblies" and ".NET Development/Tools" options is enough. This and copying the files from dnolan's comment.
LordHits
+1  A: 

I am having this same problem, and gave Simmo's solution a shot. I installed the most recent sdk for windows 7, and ran the commands he gave. I am now getting this compiler error from msbuild.

[msbuild] ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 'blah blah type' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. [blah blah.metaproj]

Any ideas what could be going on? I am using the nant msbuild task, but updated the nant config to target .net 4. Am I missing something here? Could the wrong version of msbuild be causing this error or something?

Brendan
A: 

There is a .Net 4.0 SDK available now here: http://www.microsoft.com/downloads/details.aspx?FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b&displaylang=en

I installed it but did not help with this issue. Still getting the same error.

Perry
A: 

Set Sdk40ToolsPath rather than SdkToolsPath to specify a location other than the install directory.

I hit a similar problem with AL.exe because I had just xcopied the tools onto the build machine rather than installing the SDK, so the usual registry keys were missing. I ran a build with diagnostic output (/verbosity:diagnostic) and noticed that there were several SDK tools paths defined: Sdk40ToolsPath, Sdk35ToolsPath and SdkToolsPath. Setting Sdk40ToolsPath to point to the appropriate SDK version's bin folder solved the problem for me.

IanS
A: 

I've run into the same error but in a different situation: using VS 2010 Express and trying to use Simmo's answer to explicitly set the SDK version - however WindowsSdkVer.exe (version setter tool) seems to not target Express (understandable since it's limited).

I'm using VS 2010 Express on Win 7 Prof. and it always wants to use v7.0A of the Win SDK (which does not have all the needed exes), and it deosn't matter which version I explicitly set as current using WindowsSdkVer.exe (It keeps reporting it set the current version of the SDK but for VS 2008 although though I only have 2010 Ex installed. )

So my cheap workaround was to install v7.0 WIN SDK (or another version like v7.1) and then rename its file system folder to v7.0A - basically I just lied to VS 2010 Express but it works now!

John K