I am using TeamCity to run an MSBuild script that cleans and rebuilds one of our solutions. When I deploy the dlls that are built by this process, the web server returns an error about [MyType].XmlSerializer.dll that "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded." Here are my notes so far:
- The solution is a Visual Studio 2010 solution that is targeting the .Net Framework 3.5.
- TeamCity is set to mimic this. It is set up with MSBuild version - ".Net Framework 4.0" and MSBuild ToolsVersion - "3.5". This tells TeamCity to use MSBuild 4.0 but to target the 3.5 Framework. Since we are using Visual Studio 2010, we have to use MSBuild 4.0 or it produces other errors (related to new warning codes that VS2010 uses). This appears to be working correctly and producing .Net 3.5 dlls for most of the dlls.
- The MSBuild process calls out to resgen.exe and sgen.exe to produce the resource files and XmlSerializer files respectively. Since we are using MSBuild 4.0, it looks for the Windows SDK 7.1. I have that version installed. I also have the Windows SDK 7.0 installed.
- No matter what framework I have targeted, the build process calld out to sgen.exe under WinSDK 7.1 and produces .Net Framework 4.0 [MyType].XmlSerializer.dlls. Is this correct?
As far as I can tell, my options are to:
- If I change things to target the older, v3.5, MSBuild tools, VS2010 has put warnings in the solution files that MSBuild 3.5 chokes on and breaks the build. This is not really an option.
- Try to change the path in the registry to the tools as discussed in this topic, I see no changes.
- Install VS2010 on the server. Apparently VS2010 used an intermediate WinSDK, v7.0A and they only way to get that is to install VS2010 on the server. This is not really an option.
- Change the projects to not generate XmlSerializer.dlls. This works but seems tacky since it's not really fixing the problem and I'm also worried about the performance implications.
Am I missing something? Are there any other options I missed?