Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running MSBuild fails to read SDKToolsPath

Tags:

.net

msbuild

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

like image 293
Scott Mayfield Avatar asked Apr 28 '10 16:04

Scott Mayfield


2 Answers

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

Edit to include LordHits' comment: 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.

like image 200
Simmo Avatar answered Sep 23 '22 14:09

Simmo


Simply pass GenerateSerializationAssemblies parameter with value Off to your MsBuild.

msbuild.exe /p:GenerateSerializationAssemblies=Off
like image 20
Daniel B Avatar answered Sep 20 '22 14:09

Daniel B