.NET Core 运行时是否向后兼容以前的版本? [英] Is .NET Core Runtime backwards compatible with previous releases?

查看:141
本文介绍了.NET Core 运行时是否向后兼容以前的版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我已经安装了最新版本的 .NET Core Runtime(截至目前,这是 2.2.3 版):

If I've installed the latest version of the .NET Core Runtime (as of now, that's version 2.2.3):

https://dotnet.microsoft.com/download/dotnet-core/2.2

该安装是否向后兼容以前版本的 .NET Core?

Is that one installation backwards-compatible with previous releases of .NET Core?

例如,上述安装是否与针对以下目标的应用程序兼容:

For example, will the above installation be compatible with an app which targets:

  • netcoreapp1.0
  • netcoreapp2.0
  • netcoreapp2.1
  • netcoreapp2.2

我意识到 .NET 运行时可以并行安装.但是,这并不能回答我的问题.一个 2.2 安装是否向后兼容以前的版本,因此不需要额外的运行时?

I realize that the .NET runtimes can be installed side-by-side. However, that does not answer my question. Is the one 2.2 installation backwards compatible with previous releases, such that additional runtimes are not necessary?

推荐答案

编辑.NET Core 3.x SDK 已经发布.与 v2.2 和之前的版本不同,此版本支持针对以前的运行时(即 netcoreapp2.2、netcoreapp2.1 等)的能力

Edit .NET Core 3.x SDK has been released. Unlike v2.2 and the previous releases before it, this version does not support the ability to target previous runtimes (i.e. netcoreapp2.2, netcoreapp2.1, etc)

是的.通过安装 .NET Core Runtime 2.2.3,您可以运行针对 netcoreapp2.0、netcoreapp2.1 和 netcoreapp2.2 的应用,而无需安装额外的运行时.

Yes. By installing .NET Core Runtime 2.2.3, you can run apps which target netcoreapp2.0, netcoreapp2.1, and netcoreapp2.2, without requiring additional runtimes to be installed.

微软:

...NET Core 运行时更新与主要版本兼容'band',例如 1.x 和 2.x.

...NET Core runtime updates are compatible within a major version 'band' such as 1.x and 2.x.

换句话说:(同一主要版本中的次要更新向后兼容)

In other words: (Minor updates within the same major release are backwards compatible)

微软:

此外,.NET Core SDK 的较新版本通常会维护构建针对以前版本的应用程序的能力以兼容的方式运行时

Additionally, newer releases of the .NET Core SDK generally maintain the ability to build applications that target previous versions of the runtime in a compatible manner

换句话说:(最新的 SDK 可以针对以前的运行时)

In other words: (The latest SDK can target previous runtimes)

微软:

一般来说,你只需要最新的SDK和最新的补丁版本您的应用程序所需的运行时.

In general, you only need the latest SDK and latest patch version of the runtimes required for your application.

换句话说:(一般来说,你应该只需要安装最新的 SDK/runtime)

In other words: (Generally speaking, you should only need to install the latest SDK/runtime)

微软:

随着时间的推移,当您安装 .NET Core 运行时的更新版本时和 SDK,您可能希望从你的机器.删除旧版本的运行时可能会改变运行时选择运行共享框架应用程序

Over time, as you install updated versions of the .NET Core runtime and SDK, you may want to remove outdated versions of .NET Core from your machine. Removing older versions of the runtime may change the runtime chosen to run shared framework applications

换句话说:(随着时间的推移,您并排安装其他 SDK/运行时,您应该偶尔删除旧版本,以支持最新版本)

In other words: (As you install additional SDKs/runtimes side-by-side over time, you should occasionally remove older versions, in favor of the latest)

来源:https://docs.microsoft.com/en-us/dotnet/core/versions/remove-runtime-sdk-versions?tabs=windows

根据文档:

.NET Core 2.1"指 .NET Core 运行时版本号.这.NET Core 运行时有一个主要/次要/补丁方法来进行版本控制遵循语义版本控制.

".NET Core 2.1" refers to the .NET Core Runtime version number. The .NET Core Runtime has a major/minor/patch approach to versioning that follows semantic versioning.

换句话说,.NET Core 运行时版本遵循 语义版本控制方案:

In other words, .NET Core runtime releases follow the Semantic Versioning scheme:

[主要].[次要].[补丁]

地点:

  • 重大升级带来重大变化
  • 次要升级是向后兼容以前的次要版本的功能升级
  • 补丁升级通常是对现有功能的错误修复或安全补丁(也向后兼容以前的小版本)

所以,以上问题的答案是基于语义版本控制的:

So, the answer to the above question is based on Semantic Versioning:

  • 主要升级不向后兼容以前主要版本
  • 次要和/或补丁升级在相同版本中向后兼容
  • Major upgrades are not backwards compatible with the previous major version
  • Minor and/or patch upgrades are backwards-compatible within the same version

根据这种理解,在构建/发布/恢复 .NET Core 应用程序时,它们的目标是主要版本和功能集,如运行时名称中的主要/次要版本号所示.因此,netcoreapp2.2 向后兼容 netcoreapp2.1,而后者又向后兼容 netcoreapp2.0.但都与 netcoreapp1.xnetcoreapp3.x 不兼容.

With this understanding, when .NET Core apps are built/published/restored, they target a major release and feature set as indicated by the major/minor version numbers found in the runtime name. So, netcoreapp2.2 is backwards compatible with netcoreapp2.1, which, in turn, is backwards-compatible with netcoreapp2.0. But all are incompatible with netcoreapp1.x or netcoreapp3.x.

安装一次 .NET Core 2.1.5 运行时,并假设依赖于框架的发布部署,您将能够运行针对以下目标的应用程序:

With one installation of .NET Core 2.1.5 runtime, and assuming a framework-dependent publish deployment, you would be able to run apps targeting:

  • netcoreapp2.0
  • netcoreapp2.1

但不是:

  • netcoreapp1.0(不兼容)
  • netcoreapp2.2(尚不支持)

如果安装了多个运行时,则根据安装了最高补丁的最新运行时选择确切的运行时.

If there are multiple runtimes installed, then the exact runtime is chosen based on the latest runtime installed with the highest patch.

SDK 不基于语义版本控制.但是,每个 SDK 都针对最大 .NET Core Runtime,并支持它之前的每个版本.

The SDK is not based on Semantic Versioning. However, each SDK targets a maximum .NET Core Runtime, and supports every version prior to it.

这意味着,您不需要安装多个 SDK如果您想针对多个运行时进行构建(即使您可以),请在构建服务器上进行.SDK 已经包含在当前版本(或任何先前版本)上构建应用程序所需的所有运行时开箱即用.例如,如果安装 .NET Core 2.2.105 SDK,则可以针对 netcoreapp1.0、netcoreapp2.0、netcoreapp2.1 或 netcoreapp2.2 进行构建.但是你不能为 .NET Core 2.3 或 3.0 构建.

That means, you don't need to install more than one SDK on your build server if you want to build against multiple runtimes (even though you could). The SDK already includes all the necessary runtimes to build applications on the current version (or any prior version) out-of-the-box. For example, if you install .NET Core 2.2.105 SDK, you can build for netcoreapp1.0, netcoreapp2.0, netcoreapp2.1, or netcoreapp2.2. But you can't build for .NET Core 2.3, or 3.0.

示例

假设我有一个构建服务器,它安装了最新的 .NET Core SDK(SDK 2.2.105 - 2.2.3运行时).

Suppose I have a build server, which has the latest .NET Core SDK installed (SDK 2.2.105 - 2.2.3 Runtime).

虽然安装了 SDK 2.2.105,但我可能想要构建和发布 .NET Core 2.1 应用程序:

Although, SDK 2.2.105 is installed, I might want to build and publish a .NET Core 2.1 app:

dotnet publish 
     /p:Configuration=Release -r win-x64 --self-contained false
     /p:IsWebConfigTransformDisabled=true --framework netcoreapp2.1
     /p:DebugSymbols=false /p:DebugType=None

  • /p:Configuration=Release - 配置发布
  • -r win-x64 - 目标 Windows 部署(而不是便携式).有关完整列表,请参阅此 https://docs.microsoft.com/en-us/dotnet/core/rid-catalog.
  • --self-contained false - 依赖于框架的部署(需要在主机上安装运行时)
  • /p:IsWebConfigTransformDisabled=true - 不转换 web.config 以避免 Visual Studio 生成的默认 web.config 出错(从 2.1 迁移到 2.2 时可能需要)
  • --framework netcoreapp2.1 - 明确针对运行时框架
  • /p:DebugSymbols=false/p:DebugType=None - 禁用 .PDB 文件
    • /p:Configuration=Release - configure for Release
    • -r win-x64 - target Windows deployment (rather than portable). For a complete list refer to this https://docs.microsoft.com/en-us/dotnet/core/rid-catalog.
    • --self-contained false - Framework dependent deployment (requires runtime to be installed on host)
    • /p:IsWebConfigTransformDisabled=true - do not transform web.config to avoid errors with the default web.config generated by Visual Studio (may be needed when migrating from 2.1 to 2.2)
    • --framework netcoreapp2.1 - explicitly target a runtime framework
    • /p:DebugSymbols=false /p:DebugType=None - disable .PDB files
    • 此版本可以安装在具有最新运行时的生产服务器上 .NET Core Runtime + Hosting Bundle 2.2.3 - 不需要其他运行时(或 SDK)

      This build could be installed on a Production server with the latest runtime .NET Core Runtime + Hosting Bundle 2.2.3 - no other runtimes (or SDK) are necessary

      希望这对其他人有帮助

      这篇关于.NET Core 运行时是否向后兼容以前的版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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