.NET6 vs .NET Core 3.1兼容性

发布于 2025-02-05 03:56:23 字数 205 浏览 3 评论 0原文

有一个.net6应用程序可以安全地引用.NET Core 3.1 Nuget库吗?

我使用简单的控制台应用程序测试了此情况。一切看起来都不错,没有错误/警告。但是,我没有找到任何特定信息,因此更喜欢确保。

这很重要,因为我的一个提供商之一仅提供.NET Core 3.1 Nuget软件包。知道公司需要一年左右的时间来准备.NET6 / .NETSTANDARD版本。

Is it safe to have a .NET6 application which references a .NET Core 3.1 NuGet library?

I tested this case using a simple console application. Everything looks good and there are no errors/warning. However, I haven't found any specific information so prefer to make sure.

This is important, as one of my providers offers only a .NET Core 3.1 NuGet package. Knowing the company it'll take them a year or so to prepare a .NET6 / .NETStandard version.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浊酒尽余欢 2025-02-12 03:56:23

作为.NET 6应用程序的一部分,您的.NET Core 3.1库很有可能在没有任何兼容性问题的情况下运行。

引用.NET基本原理文章会影响兼容性的变化 )强调我的):

在整个历史中,.NET试图保持高水平
从版本到版本以及跨越实现的兼容性
。网。 …

以及.NET实现的兼容性,开发人员
期望给定版本的高度兼容性
.NET的实现。 特别是为早期编写的代码
.NET Core的版本应在.NET 5或以后无缝运行
版本。
实际上,许多开发人员期望在
新发布的.NET版本也应与
引入这些API的预释放版本。

但是,不能保证兼容性。文章继续说:

本文概述了影响兼容性的变化和
.NET团队评估每种变更类型的方式。
了解.NET团队如何接近可能的破坏
更改
对于打开拉力的开发人员特别有用
请求修改现有.NET API的行为。

此外,在回答问题 .net运行时团队的成员说:

我们不能保证主要版本之间的100%兼容性。对于ASP.NET核心和运行时本身都是正确的。我们
有意做出破裂的改变,我们认为它们是
将平台向前推动和.NET的成本所需
调整生态系统足够低。

破坏可能可能会影响您.NET Core 3.1库的兼容性的变化是记录在。net 5 .net 6

但是,如果您没有在.NET Core 3.1库中遇到任何问题,则似乎没有任何记录的兼容性问题适用。

最终,当然,当您的供应商提供了.NET 6的供应商时,您将对图书馆具有更高的信心。

最后,随着.NET 5的介绍,就会变成a 更少对.net标准的需求

.NET标准是.NET API的正式规范
可用于多个.NET实现。 .net背后的动机
标准是在.NET生态系统中建立更大的均匀性。
.NET 5及以后的版本采用不同的方法来建立统一性,从而消除了大多数NET标准的需求
方案。
但是,如果您想在.NET框架之间共享代码
以及任何其他.NET实现,例如.NET Core,您的库
应该针对.NET标准2.0。 没有新版本的.net标准版本
被发布
,但是.NET 5,.NET 6,所有未来版本都将继续
支持.NET标准2.1和更早。

There is a good chance that your .NET Core 3.1 library will run without any compatibility problems as part of your .NET 6 application.

Quoting the .NET fundamentals article Changes that affect compatibility (emphasis mine):

Throughout its history, .NET has attempted to maintain a high level of
compatibility from version to version and across implementations of
.NET. …

Along with compatibility across .NET implementations, developers
expect a high level of compatibility across versions of a given
implementation of .NET. In particular, code written for an earlier
version of .NET Core should run seamlessly on .NET 5 or a later
version.
In fact, many developers expect that the new APIs found in
newly released versions of .NET should also be compatible with the
pre-release versions in which those APIs were introduced.

However, compatibility is not guaranteed. The article goes on to say:

This article outlines changes that affect compatibility and the
way in which the .NET team evaluates each type of change.
Understanding how the .NET team approaches possible breaking
changes
is particularly helpful for developers who open pull
requests that modify the behavior of existing .NET APIs.

Furthermore, in an answer to the question Clarification on backwards compatibility of .NET Core, a member of the .NET runtime team says:

We do not guarantee 100% compatibility between major versions. This is true for both ASP.NET Core and the runtime itself. We
intentionally make breaking changes where we believe that they are
necessary to move the platform forward and the cost of the .NET
ecosystem adjusting to them is low enough.

Breaking changes that could potentially affect the compatibility of your .NET Core 3.1 library are those that are documented for .NET 5 and .NET 6.

But, if you are not experiencing any problems with your .NET Core 3.1 library, it would appear that none of the documented compatibility problems apply.

Ultimately, of course, you'll have a higher degree of confidence in the library when your vendor provides one that has been updated for .NET 6.

Finally, with the introduction of .NET 5, there became a lesser need for .NET Standard:

.NET Standard is a formal specification of .NET APIs that are
available on multiple .NET implementations. The motivation behind .NET
Standard was to establish greater uniformity in the .NET ecosystem.
.NET 5 and later versions adopt a different approach to establishing uniformity that eliminates the need for .NET Standard in most
scenarios.
However, if you want to share code between .NET Framework
and any other .NET implementation, such as .NET Core, your library
should target .NET Standard 2.0. No new versions of .NET Standard will
be released
, but .NET 5, .NET 6, and all future versions will continue
to support .NET Standard 2.1 and earlier.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文