5
votes

Environment:

Windows 2008 R2 64Bit SDK installed at C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1

Framework installed at C:\Windows\Microsoft.NET\Framework64\v4.0.30319

Trying to run Nant to compile some .NET 4 classes and we are getting the following message.

The SDK for the 'net-4.0' framework is not available or not configured.:

            NAnt.Core.BuildException: The SDK for the 'net-4.0'
framework is not available or not configured.
               at NAnt.Core.Tasks.ExternalProgramBase.DetermineFilePath()
               at NAnt.Core.Tasks.ExternalProgramBase.get_ProgramFileName()
               at
NAnt.Core.Tasks.ExternalProgramBase.PrepareProcess(Process process)
               at NAnt.Core.Tasks.ExternalProgramBase.StartProcess()
               at NAnt.Core.Tasks.ExternalProgramBase.ExecuteTask()
               at NAnt.Core.Task.Execute()
               at NAnt.Core.Target.Execute()
               at NAnt.Core.Project.Execute(String targetName, Boolean
forceDependencies)
               at NAnt.Core.Project.Execute()
               at NAnt.Core.Project.Run()

In looking at the NANt.exe.config it would appear that it looks to the registry to find the applicable path for the SDK.

<project>
 <readregistry
     property="installRoot"
      key="SOFTWARE\Microsoft\.NETFramework\InstallRoot"
      hive="LocalMachine" />
 <locatesdk property="sdkInstallRoot"
 minwinsdkver="v7.0A" minnetfxver="4.0" maxnetfxver="4.0.99999"
 failonerror="false" />
</project>

The key does not exist in the registry nor does our SDK version match the minwinsdkver="v7.0A"

Anyone run into this issue and found a valid work-around?

2
If the registry keys aren't there, isn't that more of an SDK installation issue rather than NAnt?Babak Naffas
On a 64 bit machine, my 7.1 SDK is installed at: C:\Program Files\Microsoft SDKs\Windows\v7.1 (not at Program Files (x86)) maybe that's the problem?Nikolaos Georgiou

2 Answers

1
votes

Simplest solution is to add the key to the registry.

For myself the registry entry was slightly different: at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework set sdkInstallRootv2.0=C:\Program Files\Microsoft SDKs\Windows\v7.0A.

After this Nant compiled fine as expected.

0
votes

I ran into this issue yesterday. Another workaround is to mark the NAnt executable as 32 bit.

  1. Open a Developer Command Prompt
  2. Change to the directory that contains your NAnt executable.
  3. Run the following command: corflags NAnt.exe /32Bit+