简体   繁体   English

TFS 2010 为 .Net 3.5 应用程序创建 .Net 4.0 XmlSerializers DLL

[英]TFS 2010 creating .Net 4.0 XmlSerializers DLL for .Net 3.5 Application

We have a ASP.Net web application running in Visual Studio 2010 that is targeting .Net 3.5.我们有一个在 Visual Studio 2010 中运行的 ASP.Net Web 应用程序,它针对 .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.它由 TFS 2010 构建。此 Web 应用程序有几个 Web 引用,因此构建创建了一个相关的 XmlSerializers DLL。 This DLL, however, is a .Net 4.0 assembly.但是,此 DLL 是 .Net 4.0 程序集。

When I run this web application from the build, I get the error:当我从构建中运行此 Web 应用程序时,出现错误:

Could not load file or assembly 'BLAH_BLAH_WEB_APPLICATION_NAME.XmlSerializers' or one of its dependencies.无法加载文件或程序集“BLAH_BLAH_WEB_APPLICATION_NAME.XmlSerializers”或其依赖项之一。 This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.此程序集由比当前加载的运行时更新的运行时构建,无法加载。

We are using a msbuild .proj file that was working under TFS 2008 (using the "Upgrade Template" in the Build Definition).我们正在使用在 TFS 2008 下工作的 msbuild .proj 文件(使用构建定义中的“升级模板”)。 I saw this question and this one , but those mention using a specific SGen build step.我看到了这个问题,这一个,但使用特定的SGEN生成步骤那些提。 We are not.我们不是。 Additionally, the proposed solution involve hard-coding the path to the 7.0A SGen, which is just...ugly.此外,提议的解决方案涉及对 7.0A SGen 的路径进行硬编码,这只是……丑陋。

Is there a way to force the TFS 2010 build to compile this XmlSerializers DLL as a .Net 3.5 Assembly?有没有办法强制 TFS 2010 构建将此 XmlSerializers DLL 编译为 .Net 3.5 程序集?

The root problem was an invalid value in the registry.根本问题是注册表中的值无效。 The SDK35ToolsPath value under HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\4.0 was: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\4.0 下的 SDK35ToolsPath 值为:

$(Registry:HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.0A\\WinSDK-NetFx35Tools-x86@InstallationFolder) $(注册表:HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.0A\\WinSDK-NetFx35Tools-x86@InstallationFolder)

However, the build server had Windows SDK version 7.1.但是,构建服务器具有 Windows SDK 7.1 版。 So, I corrected the value to be:因此,我将值更正为:

$(Registry:HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1\\WinSDKNetFx35Tools@InstallationFolder) $(注册表:HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1\\WinSDKNetFx35Tools@InstallationFolder)

Then XmlSerializers DLL was now using .Net 2.0.然后 XmlSerializers DLL 现在使用 .Net 2.0。

I solved this issue via setting parameter named SGenToolPath我通过设置名为 SGenToolPath 的参数解决了这个问题

/p:SGenToolPath="C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\Bin" /p:SGenToolPath="C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\Bin"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM