安装了 .NET 4.5 的构建服务器能否将面向 4.0 的项目成功部署到仅安装 .NET 4.0 的服务器上? [英] Can a build server with .NET 4.5 installed successfully deploy a project targeting 4.0 to a server with only .NET 4.0 installed?

查看:28
本文介绍了安装了 .NET 4.5 的构建服务器能否将面向 4.0 的项目成功部署到仅安装 .NET 4.0 的服务器上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近在我们的持续集成构建服务器上安装了 .NET 4.5,以便它可以支持利用 .NET 4.5 功能的新项目.此构建服务器还用于构建和部署旧项目,其中一些针对 .NET 4.0.

We've recently installed .NET 4.5 onto our continuous integration build server so that it can support new projects that utilize features of .NET 4.5. This build server is also used to build and deploy older projects, as well, some of which target .NET 4.0.

在此服务器上构建以 .NET 4.0 为目标的项目,然后部署到仅安装了 .NET 4.0 的目标服务器,现在失败并显示以下错误:

Projects that target .NET 4.0 being built on this server, then deployed to a target server that has only .NET 4.0 installed are now failing with the following error:

Method not found: 'Int32 System.Environment.get_CurrentManagedThreadId()'.

Environment.CurrentManagedThreadId 是 .NET Framework 4.5 的新属性,因此运行 4.0 的服务器找不到它是有道理的.但是,我们在构建时针对 .NET 4.0,因此理论上我们不应该需要在生产服务器上安装 4.5.

Environment.CurrentManagedThreadId is a new property of .NET Framework 4.5, so it makes sense that a server running 4.0 can't find it. However, we are targeting .NET 4.0 at build time, so in theory we shouldn't need to have 4.5 installed on the production server.

总结:

  • 项目目标 4.0
  • 构建服务器已安装 4.5
  • 随后部署项目的服务器只有 .NET 4.0
  • 项目在运行时失败并出现错误 Method not found: 'Int32 System.Environment.get_CurrentManagedThreadId()'.

什么给?当 dll 由具有 .NET 4.5 的服务器构建时,是否可以在仅安装了 .NET 4.0 的服务器上成功运行 .NET 4.0 dll?

What gives? Is it possible to successfully run .NET 4.0 dlls on a server with only .NET 4.0 installed when the dlls are built by a server with .NET 4.5?

推荐答案

出现这种情况是因为 4.5 是到 4.0 的就地升级.当构建服务器编译时,默认情况下,即使您的目标是 .NET 4,它也会找到 4.5 程序集.

This occurs because 4.5 is an in-place upgrade to 4.0. When the build server compiles, by default, it will find the 4.5 assemblies even if you're targeting .NET 4.

您可以更正此问题,但您需要将 4.0 引用程序集添加到您的构建服务器(以便编译器找到它们),而不仅仅是依赖 .NET 4.5 版本.

You can correct this, but you need to add the 4.0 reference assemblies to your build server (so the compiler finds them), and not just rely on the .NET 4.5 versions.

有关详细信息,请参阅 Marc Gravell 关于该主题的博文.

For details, see Marc Gravell's blog post on the subject.

这篇关于安装了 .NET 4.5 的构建服务器能否将面向 4.0 的项目成功部署到仅安装 .NET 4.0 的服务器上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆