在 Web 部署项目期间,ASP.NET 编译器失败并出现 XmlSerializers 错误
我们在构建过程中使用 Visual Studio 2010 Web 部署项目来编译 Web 应用程序网站。我们的构建代理上未安装 Visual Studio 2010。在构建过程中,我们收到一个错误(见下文),该错误与自动生成的 Foo.XmlSerializers.dll 相关,该错误是使用比当前加载的运行时更新的运行时构建的,并且无法由 aspnet_compiler.exe 加载。
我们的项目文件以 .NET Framework v3.5 为目标。
这是错误(针对长行重新格式化):
"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]
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]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了类似的问题,具有相同的错误消息,经过多次挫折后找到了解决方案(希望能够为此提供一些想法)。
这里我们有一个带有 Windows SDK 7.1(以及使用 Vs 2008 时的 6.1)的构建服务器,用于构建面向 .NET 3.5 的 VS 2010 项目。然后使用 aspnet_compiler 预编译 Web 项目(从 v2 开始,按照 http: //msdn.microsoft.com/en-us/library/ms229863.aspx#findingthe Correctversion)。在预编译过程中,我收到了与您相同的错误消息,涉及一个项目(不是 Web,只是普通库),其中包含对 Web 服务的 Web 引用。看起来 Windows SDK 7.1 没有正确设置使用 .NET 3.5 工具的注册表路径(而 Visual Studio 则可以)。这导致 Web 引用使用 .NET 4 的目标运行时进行编译(使用反射器进行验证),因此 aspnet_compiler v2 适合。我比较了构建服务器和本地 Visual Studio 安装的注册表设置,结果显示 SDK 7.1 的 .NET 3.5 配置不好,因此我使用以下内容更正了构建服务器。我的猜测是,Web 引用 xml(在非 Web 项目中)正在使用 .NET 4 的 sgen 进行预编译,作为未使用正确的 .NET 3.5 sgen 的后备措施。应用注册表更改后,一切都很好(我的构建服务器注册表中不存在以下内容,因此我创建了它)。
作为补充说明,我还使用 WindowsSdkVer 将 7.1 设置为默认 SDK。
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).
Just as an aditional note I also used WindowsSdkVer to set 7.1 as the default SDK.