Yesterday I posted about an issue I was having with Nant and Visual Studio 2008. The solution I found from Jeffrey Palermo ultimately only got me so far. First, let me say that if I simply wanted to build the code, the solution Jeffrey provided was adequate. Where I ran into issues was when I was trying to use the "gac-install" task which is provided by the NantContrib package. I was using this task in a "test" target, which run my unit tests.
I kept receiving an error when running the "test", which included the "gac-install" as one of it's tasks:
"The SDK for the 'net-3.5' framework is not available or not configured."
So why did Jeffrey's version work and mine not?
I dug around a bit and looked at the nightly build for nant, as I read somewhere that there was 3.5 support built into nant but just not released yet. I looked into the nant.config.exe provided with the download and found that it does not yet work out of the box as it points any 3.5 project to use the 2.0 version of msbuild. (note to self, hop on SourceForge and make a bug or help with the fix)
Not one to give up, I dug into the nant configuration. Inside of the nant.exe.config there are two properties from which many other properties are derived, those two properties are
These two properties are read from the registry. The registry entries are created when you install Visual Studio or the SDK.
They're used within the nant config file as part of other properties and attributes, for example:
sdkdirectory="${path::combine(sdkInstallRoot,'bin')}"
When using the msbuild task (again provided through NantContrib) the installRoot property is set to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727, which is where msbuild.exe lives for the 2.0 framework. However registering something in the gac uses gacutil, which isn't located in the same place as the framework. gacutil.exe is located (on my machine) at C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin.
How does this all relate to nant and 3.5? Well the installRoot property is used by msbuild.exe, which in Jeffrey's example, was being set correctly, which resulted in the proper execution of my nant "compile" target. My unit test target, which uses the "gac-install" task, relies on the sdkInstallRoot property. In Jeffrey's example his config had the following element within the xml blurb he posted:
<readregistry property="sdkInstallRoot" key="SOFTWARE\Microsoft\.NETFramework\sdkInstallRootv2.0" hive="LocalMachine" failonerror="false" />
The problem, at least on my machine, is that I don't have that registry key! I was able to get everything working simply by changing what key it was pointing to. I ended up with the following (bolded text indicates what has changed):
<readregistry property="sdkInstallRoot" key="SOFTWARE\Microsoft\Microsoft SDKs\v6.0A\WinSDKNetFxTools\InstallationFolder" hive="LocalMachine" failonerror="false" />
After that change, everything is working properly.
Thanks to Jeff for his original post. It may not matter but I'm going to post my PC specs anyway, since the paths mentioned above may be OS dependent. I'm currently running Windows XP SP2 with only VS 2008 installed on it.
This blog contains the thoughts and discoveries of Tim Barcz, a technologist with a interests in computer programming technologies.