TFS 2010 creating .Net 4.0 XmlSerializers DLL for .Net 3.5 Application
Asked Answered
T

2

6

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?

Trace answered 3/9, 2010 at 13:19 Comment(2)
Did you set the target framework on the serializer project to 3.5? Check project properties.Gunn
I'm not sure what you mean by "the serializer project". The project that consumes the web references itself is targeting 3.5. Is there another setting for the web references?Trace
T
4

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.

Trace answered 8/9, 2010 at 20:49 Comment(0)
H
0

I solved this issue via setting parameter named SGenToolPath

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

Hebdomad answered 24/3, 2021 at 14:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.