Thursday, March 19, 2009

Fixing a NullReferenceException with NAnt 0.86-beta1 and .Net 3.5

My attempts at building a .Net 3.5 application with NAnt 0.86-beta1 resulted in a NullReferenceException before it ran any targets. Debugging NAnt revealed the error. The NAnt.exe.config file in my NAnt installation had this readregistry task in the framework element for the "net-3.5" framework, near line 470:

<readregistry
    property="sdkInstallRoot"
    key="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A\WinSDKNetFxTools\InstallationFolder"
    hive="LocalMachine"
    failonerror="false" />

The error is the key attribute, which I changed to:

SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.1\WinSDKNetFxTools\InstallationFolder

because I had installed the .Net 3.5 SDK after the release of .Net 3.5 SP1.