问题描述
我们有一个在 Visual Studio 2010 中运行的面向 .Net 3.5 的 ASP.Net Web 应用程序.它是由 TFS 2010 构建的.这个 Web 应用程序有几个 Web 引用,因此构建创建了一个相关的 XmlSerializers DLL.然而,这个 DLL 是一个 .Net 4.0 程序集.
We have a ASP.Net web application running in Visual Studio 2010 that is targeting .Net 3.5. It's being built by TFS 2010. This web application has a couple web references, so the build creates a related XmlSerializers DLL. This DLL, however, is a .Net 4.0 assembly.
当我从构建中运行此 Web 应用程序时,我收到错误:
When I run this web application from the build, I get the error:
无法加载文件或程序集'BLAH_BLAH_WEB_APPLICATION_NAME.XmlSerializers'或其依赖项之一.这程序集由更新的运行时构建比当前加载的运行时和无法加载.
Could not load file or assembly 'BLAH_BLAH_WEB_APPLICATION_NAME.XmlSerializers' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
我们正在使用在 TFS 2008 下运行的 msbuild .proj 文件(使用构建定义中的升级模板").我看到了这个问题和这个,但那些提到使用特定的 SGen 构建步骤.我们不是.此外,建议的解决方案涉及对 7.0A SGen 的路径进行硬编码,这只是……丑陋.
We are using a msbuild .proj file that was working under TFS 2008 (using the "Upgrade Template" in the Build Definition). I saw this question and this one, but those mention using a specific SGen build step. We are not. Additionally, the proposed solution involve hard-coding the path to the 7.0A SGen, which is just...ugly.
有没有办法强制 TFS 2010 构建将此 XmlSerializers DLL 编译为 .Net 3.5 程序集?
Is there a way to force the TFS 2010 build to compile this XmlSerializers DLL as a .Net 3.5 Assembly?
推荐答案
根本问题是注册表中的值无效.HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSBuildToolsVersions4.0 下的 SDK35ToolsPath 值为:
The root problem was an invalid value in the registry. The SDK35ToolsPath value under HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSBuildToolsVersions4.0 was:
$(注册表:HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoftSDKsWindowsv7.0AWinSDK-NetFx35Tools-x86@InstallationFolder)
$(Registry:HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SDKsWindowsv7.0AWinSDK-NetFx35Tools-x86@InstallationFolder)
但是,构建服务器具有 Windows SDK 版本 7.1.因此,我将值更正为:
However, the build server had Windows SDK version 7.1. So, I corrected the value to be:
$(注册表:HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoftSDKsWindowsv7.1WinSDKNetFx35Tools@InstallationFolder)
$(Registry:HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SDKsWindowsv7.1WinSDKNetFx35Tools@InstallationFolder)
然后 XmlSerializers DLL 现在使用 .Net 2.0.
Then XmlSerializers DLL was now using .Net 2.0.
这篇关于TFS 2010 为 .Net 3.5 应用程序创建 .Net 4.0 XmlSerializers DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!