5

环境:

Windows 2008 R2 64Bit SDK 安装在C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1

框架安装在C:\Windows\Microsoft.NET\Framework64\v4.0.30319

尝试运行 Nant 来编译一些 .NET 4 类,我们收到以下消息。

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()

在查看 NANt.exe.config 时,它似乎会查看注册表以找到 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>

注册表中不存在密钥,我们的 SDK 版本也不匹配 minwinsdkver="v7.0A"

有人遇到此问题并找到有效的解决方法吗?

4

2 回答 2

1

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.

于 2013-08-25T17:47:54.040 回答
0

我昨天遇到了这个问题。另一种解决方法是将 NAnt 可执行文件标记为 32 位。

  1. 打开开发人员命令提示符
  2. 切换到包含您的 NAnt 可执行文件的目录。
  3. 运行以下命令:corflags NAnt.exe /32Bit+
于 2016-06-01T02:11:07.503 回答