We are upgrading our TFS build system from 2012 to 2015, and are recreating our build machine. We setup the build service, installed necessary dependencies etc. The (legacy) XAML builds are working fine except for the following SGEN error:
SGEN: An attempt was made to load an assembly with an incorrect format: (location of compiled project .dll)
After much Googling and and reading a number of stack overflow articles, I am still at a loss. I referred to multiple pages including: - SGEN: An attempt was made to load an assembly with an incorrect format
I have tried
- Installing Windows SDK 8.1 (and 8.0), 6.1, SDK for Win Server 2008 .net 3.5
- Installing .Net 3.5 to 4.6.1
- Installing Visual Studio 2010, 2012, 2015
- Changing the TFS Build XMAL template file setting MSBuildPlatform to x86 (Microsoft.TeamFoundation.Build.Workflow.Activities.ToolPlatform.x86)
- Verified the Generate serialization stratgy setting is set to auto for all projects
- Changed the Build definition MSBuildPlatform and 'configuration to build' settings to x86, but this generated multiple (unrelated) errors. Ultimately the compiled projects needs to run as x64.
Also
- There is no sgen.exe in the C:/Program Files/.... although there are multiple in C:\Program Files (x86). I cannot confirm that there is an x64 version on the system at all, nor can I find where to install one.
- Setting the build 'configuration to build' option to x86 is not an option: this needs to be compiled as x64
We are building a very large code base that is owned by a different team, so changing the .SLN or .csproj files is not really a good solution unless absolutely necessary.