什么是“.NET Core”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26908049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 12:51:13  来源:igfitidea点击:

What is ".NET Core"?

.net.net-core

提问by Petr Abdulin

Recently in an official .NET Framework Blogit was announced that .NET Core is going open source.

最近在官方.NET Framework 博客中宣布.NET Core 将开源

Ironically, the author mentions that what.NET Core is will be explained in the next post. Some more details are mentioned in another announcement post.

具有讽刺意味的是,作者提到什么是.NET Core 将在下一篇文章中解释。在另一篇公告帖子中提到了更多细节。

From a supplied diagram:

从提供的图表中:

.NET Core diagram

.NET 核心图

and articles text itself, I would assume that .NET Core (beside obvious things like being open-sourced) is a modular re-implementation of the full .NET. I.e. framework components are loaded as necessary, much like NuGet packages are loaded now. And now ASP.NET 5 is one of the modules that is already implemented. Is my understanding of .NET Core correct? Maybe I'm missing something?

和文章文本本身,我认为 .NET Core(除了开源等显而易见的东西)是完整 .NET 的模块化重新实现。即根据需要加载框架组件,就像现在加载 NuGet 包一样。现在 ASP.NET 5 是已经实现的模块之一。我对 .NET Core 的理解正确吗?也许我错过了什么?



I have found a recent articlewhich I found both short and very good. It covers .NET Standard, .NET Core, and .NET Framework and their relationship. I highly recommend it.

我找到了最近的一篇文章,我觉得它既简短又非常好。它涵盖了 .NET Standard、.NET Core 和 .NET Framework 及其关系。我强烈推荐它。

回答by CodeCaster

From the .NET blog Announcing .NET 2015 Preview: A New Era for .NET:

来自 .NET 博客宣布 .NET 2015 预览:.NET 的新时代

.NET Core has two major components. It includes a small runtime that is built from the same codebase as the .NET Framework CLR. The .NET Core runtime includes the same GC and JIT (RyuJIT), but doesn't include features like Application Domains or Code Access Security. The runtime is delivered via NuGet, as part of the [ASP.NET Core] package.

.NET Core also includes the base class libraries. These libraries are largely the same code as the .NET Framework class libraries, but have been factored (removal of dependencies) to enable us to ship a smaller set of libraries. These libraries are shipped as System.* NuGet packages on NuGet.org.

.NET Core 有两个主要组件。它包含一个小型运行时,它是从与 .NET Framework CLR 相同的代码库构建的。.NET Core 运行时包括相同的 GC 和 JIT (RyuJIT),但不包括应用程序域或代码访问安全性等功能。运行时通过 NuGet 提供,作为 [ASP.NET Core] 包的一部分。

.NET Core 还包括基类库。这些库在很大程度上与 .NET Framework 类库的代码相同,但已被分解(删除依赖项)以使我们能够提供较小的库集。这些库在 NuGet.org 上作为 System.* NuGet 包提供。

And:

和:

[ASP.NET Core] is the first workload that has adopted .NET Core. [ASP.NET Core] runs on both the .NET Framework and .NET Core. A key value of [ASP.NET Core] is that it can run on multiple versions of [.NET Core] on the same machine. Website A and website B can run on two different versions of .NET Core on the same machine, or they can use the same version.

[ASP.NET Core] 是第一个采用 .NET Core 的工作负载。[ASP.NET Core] 可在 .NET Framework 和 .NET Core 上运行。[ASP.NET Core] 的一个关键价值在于它可以在同一台机器上运行多个版本的 [.NET Core]。网站 A 和网站 B 可以在同一台机器上的两个不同版本的 .NET Core 上运行,也可以使用相同的版本。

In short: first, there was the Microsoft .NET Framework, which consists of a runtime that executes application and library code, and a nearly fully documentedstandard class library.

简而言之:首先是Microsoft .NET Framework,它包含一个执行应用程序和库代码的运行时,以及一个几乎完整记录的标准类库

The runtime is the Common Language Runtime, which implements the Common Language Infrastructure, works with The JIT compilerto run the CIL (formerly MSIL) bytecode.

运行时是公共语言运行时,它实现了公共语言基础结构,与JIT 编译器一起运行CIL(以前的 MSIL)字节码

Microsoft's specification and implementation of .NET were, given its history and purpose, very Windows- and IIS-centered and "fat". There are variations with fewer libraries, namespaces and types, but few of them were useful for web or desktop development or are troublesome to port from a legal standpoint.

考虑到其历史和目的,Microsoft 的 .NET 规范和实现非常以 Windows 和 IIS 为中心且“胖”。有一些库、名称空间和类型较少的变体,但其中很少有对 Web 或桌面开发有用的,或者从法律角度来看移植起来麻烦

So in order to provide a non-Microsoft version of .NET, which could run on non-Windows machines, an alternative had to be developed. Not only the runtime has to be ported for that, but also the entire Framework Class Library to become well-adopted. On top of that, to be fully independent from Microsoft, a compiler for the most commonly used languages will be required.

因此,为了提供可以在非 Windows 机器上运行的非 Microsoft 版本的 .NET,必须开发替代方案。不仅运行时必须为此移植,而且整个框架类库也必须被广泛采用。最重要的是,要完全独立于 Microsoft,需要一个用于最常用语言的编译器。

Monois one of few, if not the only alternative implementation of the runtime, which runs on various OSes besides Windows, almost all namespaces from the Framework Class Library as of .NET 4.5and a VBand C# compiler.

Mono是少数几个运行时的替代实现之一,如果不是唯一的替代实现,它运行在除 Windows 之外的各种操作系统上, 几乎所有来自 .NET 4.5 的框架类库的命名空间以及VBC# 编译器

Enter .NET Core: an open-source implementation of the runtime, and a minimal base class library. All additional functionality is delivered through NuGet packages, deploying the specific runtime, framework libraries and third-party packages with the application itself.

进入 .NET Core:运行时的开源实现和最小的基类库。所有附加功能都通过 NuGet 包提供,使用应用程序本身部署特定的运行时、框架库和第三方包。

ASP.NET Core is a new version of MVC and WebAPI, bundled together with a thin HTTP server abstraction, that runs on the .NET Core runtime - but also on the .NET Framework.

ASP.NET Core 是 MVC 和 WebAPI 的新版本,与瘦 HTTP 服务器抽象捆绑在一起,运行在 .NET Core 运行时 - 但也运行在 .NET Framework 上。

回答by Hans Passant

It is a sub-set of the .NET Framework, started with the Compact Framework edition. It progressed into Silverlight, Windows Store and Windows Phone. It focused on keeping the deployment small, suitable for quick downloads and devices with limited storage capabilities. And it is easier to bring up on non-Windows platforms, and surely this was the reason it was chosen as the open sourced edition. The "difficult" and "expensive" parts of the CLR and the base class libraries are omitted.

它是 .NET Framework 的一个子集,从 Compact Framework 版本开始。它发展到 Silverlight、Windows Store 和 Windows Phone。它专注于保持部署规模小,适用于快速下载和存储能力有限的设备。而且在非 Windows 平台上更容易启动,这肯定是它被选为开源版本的原因。省略了 CLR 和基类库的“困难”和“昂贵”部分。

Otherwise, it is always easy to recognize when you target such a framework version, because lots of goodies will be missing. You'll be using a distinct set of reference assemblies that only expose what is supported by the runtime. It is stored on your machine in the C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCoredirectory.

否则,当您针对这样的框架版本时总是很容易识别,因为会丢失很多好东西。您将使用一组不同的引用程序集,这些程序集仅公开运行时支持的内容。它存储在您机器上的C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore目录中。



Update: after the .NET Core 2.0 release I've seen some representative numbers that gives a decent insight. They have been hard at work back-porting framework APIs to .NET Core over the past two years. .NET Core 1.0 originally supported 13,000 APIs. .NET Core 2.0 added 20,000 APIs, bringing the total to 32,000 and allowing about 70% of existing NuGet packages to be ported. There are a set of APIs that are too heavily wedded to Windows to be easy to port to Linux and MacOS. Covered by the recently released Windows Compatibility Pack, it adds another 20,000 APIs.

更新:在 .NET Core 2.0 发布后,我看到了一些具有代表性的数字,它们提供了一个不错的见解。在过去的两年里,他们一直在努力将框架 API 向后移植到 .NET Core。.NET Core 1.0 最初支持 13,000 个 API。.NET Core 2.0 添加了 20,000 个 API,使总数达到 32,000 个,并允许移植大约 70% 的现有 NuGet 包。有一组 API 与 Windows 紧密结合,无法轻松移植到 Linux 和 MacOS。在最近发布的 Windows 兼容包中,它增加了另外 20,000 个 API。

回答by Petr Abdulin

I have found a recent articlewhich I found both short and very good. It covers .NET Standard, .NET Core and .NET Framework and their relationship. I highly recommend it. Unfortunately, I have no time to adapt and put it here.

我找到了最近的一篇文章,我觉得它既简短又非常好。它涵盖了 .NET Standard、.NET Core 和 .NET Framework 及其关系。我强烈推荐它。不幸的是,我没有时间适应并把它放在这里。

Original answer content below:

原回答内容如下:



So, based on the latest official entryon the subject, here are some key points as I see them:

因此,根据有关该主题的最新官方条目,以下是我所看到的一些关键点:

.NET Core is essentially a fork of the .NET Framework whose implementation is also optimized around factoring concerns.

We think of .NET Core as not being specific to either .NET Native nor ASP.NET 5 – the BCL and the runtimes are general purpose and designed to be modular. As such, it forms the foundation for all future .NET verticals.

.NET Core 本质上是 .NET Framework 的一个分支,它的实现也围绕因式分解问题进行了优化。

我们认为 .NET Core 不是特定于 .NET Native 或 ASP.NET 5 - BCL 和运行时是通用的,并且设计为模块化。因此,它构成了未来所有 .NET 垂直领域的基础。

So .NET Native and ASP.NET 5 are just a test "subjects" for new framework configuration, partially this maybe because they are quite different:

所以 .NET Native 和 ASP.NET 5 只是新框架配置的测试“主题”,部分原因可能是因为它们完全不同:

Enter image description here

在此处输入图片说明

See, they even need separate low-level, but a major part of BCL is still common:

看,他们甚至需要单独的低级,但 BCL 的主要部分仍然是通用的:

We think of .NET Core as not being specific to either .NET Native nor ASP.NET 5 – the BCL and the runtimes are general purpose and designed to be modular. As such, it forms the foundation for all future .NET verticals.

我们认为 .NET Core 不是特定于 .NET Native 或 ASP.NET 5 - BCL 和运行时是通用的,并且设计为模块化。因此,它构成了未来所有 .NET 垂直领域的基础。

I.e., magenta rectangles on top will be added massively with new App Models, but the base will remain common.

即,顶部的洋红色矩形将与新的 App 模型一起大量添加,但底部将保持通用。

NuGet deployment:

NuGet 部署:

In contrast to the .NET Framework, the .NET Core platform will be delivered as a set of NuGet packages. We've settled on NuGet because that's where the majority of the library ecosystem already is.

与 .NET Framework 相比,.NET Core 平台将作为一组 NuGet 包提供。我们已经决定使用 NuGet,因为它已经是大多数图书馆生态系统的所在。

Relationship with current frameworks:

与当前框架的关系:

For Visual Studio 2015 our goal is to make sure that .NET Core is a pure subset of the .NET Framework. In other words, there wouldn't be any feature gaps. After Visual Studio 2015 is released our expectation is that .NET Core will version faster than the .NET Framework. This means that there will be points in time where a feature will only be available on the .NET Core based platforms.

对于 Visual Studio 2015,我们的目标是确保 .NET Core 是 .NET Framework 的纯子集。换句话说,不会有任何功能差距。在 Visual Studio 2015 发布后,我们期望 .NET Core 的版本比 .NET Framework 更快。这意味着在某些时间点,某个功能将仅在基于 .NET Core 的平台上可用。

Summary:

概括:

The .NET Core platform is a new .NET stack that is optimized for open source development and agile delivery on NuGet. We're working with the Mono community to make it great on Windows, Linux and Mac, and Microsoft will support it on all three platforms.

We're retaining the values that the .NET Framework brings to enterprise class development. We'll offer .NET Core distributions that represent a set of NuGet packages that we tested and support together. Visual Studio remains your one- stop-shop for development. Consuming NuGet packages that are part of a distribution doesn't require an Internet connection.

.NET Core 平台是一个新的 .NET 堆栈,针对 NuGet 上的开源开发和敏捷交付进行了优化。我们正在与 Mono 社区合作,使其在 Windows、Linux 和 Mac 上表现出色,Microsoft 将在所有三个平台上支持它。

我们将保留 .NET Framework 为企业级开发带来的价值。我们将提供 .NET Core 发行版,代表我们一起测试和支持的一组 NuGet 包。Visual Studio 仍然是您的一站式开发商店。使用作为分发一部分的 NuGet 包不需要 Internet 连接。

Basically this can be thought as a .NET 4.6 with a changed distribution model, which, simultaneously, is being in a process of becoming open source.

基本上,这可以被认为是具有更改分发模型的 .NET 4.6,同时,它正在成为开源的过程中。

回答by Set

The current documentationhas a good explanation of what .NET Core is, areas to use and so on. The following characteristics best define .NET Core:

当前文档很好地解释了 .NET Core 是什么、使用领域等。以下特征最能定义 .NET Core:

Flexible deployment: Can be included in your app or installed side-by-side user- or machine-wide.

Cross-platform: Runs on Windows, macOS and Linux; can be ported to other OSes. The supported operating systems (OSes), CPUs and application scenarios will grow over time, provided by Microsoft, other companies, and individuals.

Command-line tools: All product scenarios can be exercised at the command-line.

Compatible: .NET Core is compatible with .NET Framework, Xamarin and Mono, via the .NET Standard Library.

Open source: The .NET Core platform is open source, using MIT and Apache 2 licenses. Documentation is licensed under CC-BY. .NET Core is a .NET Foundation project.

Supported by Microsoft: .NET Core is supported by Microsoft, per .NET Core Support

灵活部署:可以包含在您的应用程序中或在用户或机器范围内并排安装。

跨平台:在 Windows、macOS 和 Linux 上运行;可以移植到其他操作系统。支持的操作系统 (OS)、CPU 和应用程序场景将随着时间的推移而增长,由 Microsoft、其他公司和个人提供。

命令行工具:所有产品场景都可以在命令行上运行。

兼容:.NET Core 通过 .NET 标准库与 .NET Framework、Xamarin 和 Mono 兼容。

开源:.NET Core 平台是开源的,使用 MIT 和 Apache 2 许可证。文档根据 CC-BY 获得许可。.NET Core 是一个 .NET Foundation 项目。

受 Microsoft 支持:根据 .NET Core 支持,Microsoft 支持 .NET Core

And here is what .NET Core includes:

以下是 .NET Core 包含的内容:

A .NET runtime, which provides a type system, assembly loading, a garbage collector, native interoperability and other basic services.

A set of framework libraries, which provide primitive data types, application composition types and fundamental utilities.

A set of SDK tools and language compilers that enable the base developer experience, available in the .NET Core SDK.

The 'dotnet' application host, which is used to launch .NET Core applications. It selects the runtime and hosts the runtime, provides an assembly loading policy and launches the app. The same host is also used to launch SDK tools in much the same way.

.NET 运行时,提供类型系统、程序集加载、垃圾收集器、本机互操作性和其他基本服务。

一组框架库,提供原始数据类型、应用程序组合类型和基本实用程序。

一组 SDK 工具和语言编译器,可在 .NET Core SDK 中提供基本的开发人员体验。

“dotnet”应用程序主机,用于启动 .NET Core 应用程序。它选择运行时并托管运行时,提供程序集加载策略并启动应用程序。同样的主机也用于以几乎相同的方式启动 SDK 工具。

回答by farfareast

.NET Core is a new cross-platform implementation of .NET standards (ECMA 335) similar to Mono but done by Microsoft itself.

.NET Core 是 .NET 标准 (ECMA 335) 的新跨平台实现,类似于 Mono,但由 Microsoft 自己完成。

See docs.microsoft.com

请参阅docs.microsoft.com

回答by Manish Jain

Microsoft recognized the future web open source paradigm and decided to open .NET to other operating systems. .NET Core is a .NET Framework for Mac and Linux. It is a “lightweight” .NET Framework, so some features/libraries are missing.

Microsoft 认识到未来的 Web 开源范式,并决定将 .NET 开放给其他操作系统。.NET Core 是适用于 Mac 和 Linux 的 .NET 框架。它是一个“轻量级”的 .NET 框架,因此缺少一些功能/库。

On Windows, I would still run .NET Framework and Visual Studio 2015. .NET Core is more friendly with the open source world like Node.js, npm, Yeoman, Docker, etc.

在 Windows 上,我仍然会运行 .NET Framework 和 Visual Studio 2015。.NET Core 对Node.js、npm、YeomanDocker等开源世界更加友好。

You can develop full-fledged web sites and RESTful APIs on Mac or Linux with Visual Studio Code + .NET Core which wasn't possible before. So if you love Mac or Ubuntu and you are a .NET developer then go ahead and set it up.

您可以使用 Visual Studio Code + .NET Core 在 Mac 或 Linux 上开发成熟的网站和 RESTful API,这在以前是不可能的。因此,如果您喜欢 Mac 或 Ubuntu 并且您是 .NET 开发人员,那么请继续进行设置。

For Monovs. .NET Core, Mono was developed as a .NET Framework for Linux which is now acquired by Microsoft (company called Xamarin) and used in mobile development. Eventually, Microsoft may merge/migrate Mono to .NET Core. I would not worry about Mono right now.

对于Mono与 .NET Core,Mono 被开发为 Linux 的 .NET 框架,现在被微软(公司名为Xamarin)收购并用于移动开发。最终,Microsoft 可能会将 Mono 合并/迁移到 .NET Core。我现在不会担心 Mono。

回答by joym8

I was trying to create a new project in Visual Studio 2017 today (recently upgraded from Visual Studio 2015) and noticed new set of choices for the type of project. Either they're new or it's been a while since I started a new project!! :)

我今天试图在 Visual Studio 2017 中创建一个新项目(最近从 Visual Studio 2015 升级)并注意到项目类型的新选择集。要么他们是新来的,要么我开始一个新项目已经有一段时间了!!:)

Visual Studio Screenshot

Visual Studio 屏幕截图

I came across this documentation linkand found it very useful, so I am sharing. The details of the bullets are also provided in the article. I am just posting bullets here:

我遇到了这个文档链接,发现它非常有用,所以我分享一下。文章中还提供了子弹的详细信息。我只是在这里张贴子弹:

You should use .NET Core for your server application when:

You have cross-platform needs.
You are targeting microservices.
You are using Docker containers.
You need high performance and scalable systems.
You need side by side of .NET versions by application.

You should use .NET Framework for your server application when:

Your application currently uses .NET Framework (recommendation is to extend instead of migrating)
You need to use third-party .NET libraries or NuGet packages not available for .NET Core.
You need to use .NET technologies that are not available for .NET Core.
You need to use a platform that doesn't support .NET Core.

在以下情况下,您应该将 .NET Core 用于您的服务器应用程序:

You have cross-platform needs.
You are targeting microservices.
You are using Docker containers.
You need high performance and scalable systems.
You need side by side of .NET versions by application.

在以下情况下,您应该将 .NET Framework 用于您的服务器应用程序:

Your application currently uses .NET Framework (recommendation is to extend instead of migrating)
You need to use third-party .NET libraries or NuGet packages not available for .NET Core.
You need to use .NET technologies that are not available for .NET Core.
You need to use a platform that doesn't support .NET Core.

This linkprovides a glossary of .NET terms.

此链接提供了 .NET 术语表。

回答by Salah Alshaal

From Microsoft's Website:

微软的网站

.NET Core refers to several technologies including .NET Core, ASP.NET Core and Entity Framework Core.

.NET Core 是指多种技术,包括 .NET Core、ASP.NET Core 和 Entity Framework Core。

These technologies are different than native .NET in that they run using CoreCLR runtime (used in the Universal Windows Platform).

这些技术与本机 .NET 的不同之处在于它们使用 CoreCLR 运行时(在通用 Windows 平台中使用)运行。

As you mentioned in your question, .NET Core is not only open-source, but portable as well [runs on MacOS, Windows, and Linux]

正如您在问题中提到的,.NET Core 不仅是开源的,而且是可移植的 [在 MacOS、Windows 和 Linux 上运行]

The internals of .NET Core are also optimised to not use different modules from its core library unless it is required by the application.

.NET Core 的内部也经过优化,不会使用其核心库中的不同模块,除非应用程序需要。

回答by itsikha

Microsoft just announced .NET Core v 3.0, which is a much-improved version of .NET Core.

Microsoft 刚刚发布了 .NET Core v 3.0,这是 .NET Core 的大幅改进版本。

For more details visit this great article: Difference Between .NET Framework and .NET Corefrom April 2019.

有关更多详细信息,请访问这篇很棒的文章: 2019 年 4 月的.NET Framework 和 .NET Core 之间的差异

回答by Waleed Naveed

.NET Core is a free and open-source, managed computer software framework for Windows, Linux, and macOS operating systems. It is an open source, cross platform successor to .NET Framework.

.NET Core 是适用于 Windows、Linux 和 macOS 操作系统的免费开源托管计算机软件框架。它是 .NET Framework 的开源、跨平台继承者。

.NET Core applications are supported on Windows, Linux, and macOS. In a nutshell .NET Core is similar to .NET framework, but it is cross-platform, i.e., it allows the .NET applications to run on Windows, Linux and MacOS. .NET framework applications can only run on the Windows system. So the basic difference between .NET framework and .NET core is that .NET Core is cross platform and .NET framework only runs on Windows.

.NET Core 应用程序在 Windows、Linux 和 macOS 上受支持。简而言之,.NET Core 类似于.NET 框架,但它是跨平台的,即允许.NET 应用程序在Windows、Linux 和MacOS 上运行。.NET 框架应用程序只能在 Windows 系统上运行。所以 .NET framework 和 .NET core 的基本区别在于 .NET Core 是跨平台的,而 .NET framework 只运行在 Windows 上。

Furthermore, .NET Core has built-in dependency injection by Microsoft and you do not have to use third-party software/DLL files for dependency injection.

此外,.NET Core 具有 Microsoft 内置的依赖注入,您不必使用第三方软件/DLL 文件进行依赖注入。