可以生成服务器与.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?

查看:815
本文介绍了可以生成服务器与.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框架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
  • 在项目在运行时失败,出现错误未找到方法:的Int32 System.Environment.get_CurrentManagedThreadId()
  • Project targets 4.0
  • Build server has 4.5 installed
  • The server on which the project is then deployed has only .NET 4.0
  • Project fails at runtime with error Method not found: 'Int32 System.Environment.get_CurrentManagedThreadId()'.

怎么办?是否有可能成功地只用.NET 4.0安装在服务器上运行.NET 4.0的DLL时,DLL是由服务器构建在.NET 4.5?

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。当构建服务器编译,默认情况下,它会发现4.5组件,即使你的目标.NET 4。

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.

有关详细信息,请参阅主题马克Gravell的博客文章一>

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

这篇关于可以生成服务器与.NET 4.5成功安装部署目标4.0仅与.NET 4.0的服务器上安装一个项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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