NAnt 0.92 Issues Building .NET 2.0 Projects on x64 Windows
It's more than a year since NAnt 0.92 has been released, but if you take a look at the project issues page, many of them still report problems related to finding different versions of SDKs. I've encountered a similar issue when building a legacy .NET 2.0 solution after I upgraded NAnt from 0.91 to 0.92, therefore I decided to get to the bottom of this.
The build process failed with the following error:
[msbuild] C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Microsoft.Common.targets(1960,9): error MSB3011: "C:\Windows\Microsoft.NET\Framework64\v2.0.50727\AL.exe" was not found. Either 1) Install the .NET Framework SDK, which will install AL.exe. Or 2) Pass the correct location of AL.exe into the "ToolPath" parameter of the AL task.
Of course I had .NET Framework 2.0 SDK installed since the build worked flawlessly before upgrading NAnt. The paths in the error message do give a hint at the cause of the problem, though: the missing file is being searched for in
Framework64 subfolder instead of in
Framework. Obviously 64-bit version of MSBuild is being used requiring an x64 version of SDK as well. This assumption can be confirmed by checking more of the build output; there was another warning there, a couple of lines before:
[msbuild] Could not locate the .NET Framework SDK. The task is looking for the path to the .NET Framework SDK at the location specified in the SDKInstallRootv2.0 value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework. You may be able to solve the problem by doing one of the following: 1.) Install the .NET Framework SDK. 2.) Manually set the above registry key to the correct location.
HKLM\SOFTWARE\Microsoft is being checked, instead of
HKLM\Software\Wow6432Node\Microsoft where the x86 SDK has put its entries. Solving the problem should be trivial now: download and install the x64 version of .NET Framework 2.0 SDK. If you're using Windows 8 as I am, the setup will fail, so you'll need to extract it and run
install.exe inside it with administrative privileges manually. As expected, the build succeeded afterwards just like it did before with NAnt 0.91.
It was still bothering me, why such a breaking change wouldn't be mentioned in the release notes. Well, actually it is:
Removed runtime support for .NET/Mono 1.* Frameworks (target support for .NET/Mono 1.* Frameworks still remains)
It's just not obvious how this change is related to the above issues. Up until version 0.91 NAnt was still built on .NET Framework 1.1 which never supported x64 and was therefore always executed in x86 context. NAnt 0.92 is built on .NET Framework 2.0 with
AnyCPU flag, causing it to run in 64 bit on x64 Windows. As such it scans the x64 part of the registry and finds paths to x64 build tools, requiring them to be installed.