TFS 2010 creating .Net 4.0 XmlSerializers DLL for .Net 3.5 Application

强颜欢笑 提交于 2019-12-18 06:13:55

问题


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.

When I run this web application from the build, I get the error:

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.

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.

Is there a way to force the TFS 2010 build to compile this XmlSerializers DLL as a .Net 3.5 Assembly?


回答1:


The root problem was an invalid value in the registry. The SDK35ToolsPath value under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0 was:

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

However, the build server had Windows SDK version 7.1. So, I corrected the value to be:

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

Then XmlSerializers DLL was now using .Net 2.0.



来源:https://stackoverflow.com/questions/3636103/tfs-2010-creating-net-4-0-xmlserializers-dll-for-net-3-5-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!