4

We're using Visual Studio 2010 Web deployment projects to compile web-application websites during our build. Visual Studio 2010 is not installed on our build-agents. We get an error (see below) during the build relating to the automatically-generated Foo.XmlSerializers.dll being built with a runtime newer than the currently loaded runtime and cannot be loaded by aspnet_compiler.exe.

We're targeting .NET Framework v3.5 in our project files.

Here's the error (reformatted for long lines):

"C:\BuildAgent\work\3836706d661b8a05\project\src\Foo.FrontEnd.WdpSite\
Foo.FrontEnd.WdpSite.wdproj" (Build target) (1) ->
  (AspNetCompiler target) ->
    ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 
    'Foo.FrontEnd.Site.XmlSerializers' or one of its dependencies. 
    This assembly is built by a runtime newer than the currently loaded 
    runtime and cannot be loaded.   
[C:\BuildAgent\work\3836706d661b8a05\project\src\Foo.FrontEnd.WdpSite\
Foo.FrontEnd.WdpSite.wdproj]
Peter Mounce
  • 4,105
  • 3
  • 34
  • 65

1 Answers1

1

I was having a similar issue, with the same error message, and after lots of frustration found the solution (which hopefully will give some ideas for this).

Here we have a build server with Windows SDK 7.1 (and 6.1 from when using Vs 2008) building VS 2010 projects targeting .NET 3.5. The web projects are then pre-compiled with aspnet_compiler (from v2 as per http://msdn.microsoft.com/en-us/library/ms229863.aspx#findingthecorrectversion). During pre-compilation I received the same error message as yourself for a project (not web, just normal library) with a web reference to a web-service. It looks like Windows SDK 7.1 doesn't set up the registry paths correctly for using .NET 3.5 tools (while Visual Studio does). This caused the web references to be compiled with a target runtime of .NET 4 (validated using reflector) so aspnet_compiler v2 had a fit. I compared the registry settings of the build server and my local visual studio install which showed the .NET 3.5 configuration for SDK 7.1 was not good, so I corrected the build server with the below. My guess is the web reference xml (in the non-web project) was being precompiled with sgen for .NET 4 as a fall back for not using the correct .NET 3.5 sgen. Once the registry change was applied everything was fine (the below didn't exist in my build server registry so I created it).

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDK-NetFx35Tools-x86]
"ComponentName"="Windows SDK .NET Framework 3.5 Multi-targeting Utilities"
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\"
"ProductVersion"="7.1.7600.0.30514"

Just as an aditional note I also used WindowsSdkVer to set 7.1 as the default SDK.

adz21c
  • 11
  • 1