Building .Net projects with Nant – Unable to find sdkInstallRoot keys

A quick but incredibly annoying issue.

I upgrade my machine recently to use Visual Studio 2008 so that I could upgrade a .net 1.1 project to .net 2.0. As I mentioned in the last post, this has caused a great deal of problems and a little bit of fodder for this blog. This issue however, takes the cake.

I had to upgrade to the new version of nant, which we use to perform command-line building on our continuous build server. Unfortunately nant does not support VS2008 solutions files, only 2003-2005, despite the fact it supports building to .Net 2.0 which is what I needed to do. This was easily gotten around by using exec to call msbuild and compile using the microsoft command line tool.

I could have converted the entire thing to msbuild, however the nant script does a lot more than just compile, it runs tests and does precompilation copying and generating that would be painful to move. Also it needs to play nicely with an ant script that originally calls it, which nant does quite well.

The issue occured however when I set nant to target .Net 2.0. Strictly speaking I didn’t have to do this, as msbuild took care of it when checking the solution file, however I like things to be tidy and didn’t want nant targeting .Net 1.1 when we’re building for 2.0.

It crashed almost immediately when started claiming it couldn’t find the sdkinstallroot key, the key that determines where on the file system the relevant SDK’s can be found (in order to link against them). I checked the registry and indeed, no sdkInstallKey existed for any version other than 1.1 despite the fact that VS2008, when installed, targets .Net 2.0, 3.0 and 3.5.

It turns out that VS2008 targets these frameworks by understanding that both 2.0 is a subset of 3.0, which is a subset of 3.5 – each new version has expanded on the previous, rather than replacing it or changing the interface. Thus, it can build for 2.0 simply by leaving out links to all parts of the framework which don’t exist in 2.0.

What this means for us though is no sdkInstallRoot… in real terms, no sdk at all.

The solution is as simple as the final explanation, simply install the microsoft SDK for the version you’re targeting and it’s as right as rain. When the sdk is installed, the key is added and nant finds it exactly as it expects to – it just means you need to install a copy of all the sdk’s you need alongside the visual studio built-in libraries.

Advertisements

One thought on “Building .Net projects with Nant – Unable to find sdkInstallRoot keys

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s