在.NET 4的生成过程中找不到LC.exe文件

迁移到.net 4.0时出现问题,尝试构建时出现以下错误。

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1917,9): error MSB3086: Task could not find "LC.exe" using the SdkToolsPath "" or the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A". Make sure the SdkToolsPath is set and the tool exists in the correct processor specific location under the SdkToolsPath and that the Microsoft Windows SDK is installed External Program Failed: C:\windows\microsoft.net\framework\v4.0.30319\MSBuild.exe (return code was 1) 

最新版本的microsoft windows sdk安装在机器上,但版本是v7.1。 为了解决这个问题,我将以下几点放在注册表项中

  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\InstallationFolder to C:\Program Files\Microsoft SDKs\Windows\v7.1\. 

这工作有点但我觉得有点脏将7.0A注册表项指向7.1安装。 有没有人有更好的解决方案来解决这个问题?

看一下: 运行MSBuild无法读取SDKToolsPath

在其中一个答案中, Simmo建议将SDK的默认版本设置为7.1。 Windows SDK的7.1版比Visual Studio 2010附带的版本(7.0a)更新。 LC.exe包含在7.1中,一旦您使用WindowsSdkVer.exe将7.1作为默认版本,一切运行正常。

然而,有两个小问题:1)WindowsSdkVer.exe允许您从VS 2005和VS 2008中进行选择,但它没有列出VS 2010.我只是设置了VS 2008的默认版本,它在2010年工作。

2)WindowsSdkVer.exe -version:v7.1对我来说没有用,但WindowsSdkVer.exe没有任何参数,它带来了一个windows界面。

我刚遇到这个问题,这是因为我们的构建服务器使用VS 2010构建,我在VS 2015中打开并修改了我的解决方案。

.sln文件的标题来自:

 Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 

 Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 

显然,这足以使tfs(2010和使用visual studio 2010)想要寻找更高版本的sdk工具(未安装,在本例中为v8.0A)。

将* .sln文件中的标题设置回VS 2010版本解决了我的问题。