.NET Core 和 .NET Standard 类库项目类型之间有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42939454/
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 09:54:01  来源:igfitidea点击:

What is the difference between .NET Core and .NET Standard Class Library project types?

.net.net-coreclass-library.net-standard

提问by Gigi

In Visual Studio, there are at least 3 different types of class library you can create:

在 Visual Studio 中,您可以创建至少 3 种不同类型的类库:

  • Class Library (.NET Framework)
  • Class Library (.NET Standard)
  • Class Library (.NET Core)
  • 类库(.NET 框架)
  • 类库(.NET 标准)
  • 类库 (.NET Core)

While the first is what we've been using for years, a major point of confusion I've been having is when to use the .NET Standard and .NET Core class library types. I've been bitten by this recently when attempting to multi-target different framework versions, and creating a unit test project.

虽然第一个是我们多年来一直在使用的,但我一直遇到的一个主要困惑点是何时使用 .NET Standard 和 .NET Core 类库类型。我最近在尝试针对不同的框架版本进行多目标定位创建单元测试项目时被这个问题所困扰。

So, what is the difference between Class Library (.NET Standard)and Class Library (.NET Core), why do both exist, and when should we use one over the other?

那么,类库 (.NET Standard)类库 (.NET Core)之间有什么区别,为什么两者都存在,我们什么时候应该使用一个?

采纳答案by Shaun Luttin

When should we use one over the other?

我们什么时候应该使用一个?

The decision is a trade-off between compatibility and API access.

该决定是兼容性和 API 访问之间的权衡。

Use a .NET Standard library when you want to increase the number of apps that will be compatible with your library, and you are okay with a decrease in the .NET API surface area your library can access.

当您想要增加与您的库兼容的应用程序数量并且您可以减少库可以访问的 .NET API 表面积时,请使用 .NET Standard 库。

Use a .NET Core library when you want to increase the .NET API surface area your library can access, and you are okay with allowing only .NET Core apps to be compatible with your library.

当您想要增加您的库可以访问的 .NET API 表面积时,请使用 .NET Core 库,并且您可以只允许 .NET Core 应用程序与您的库兼容。

For example, a library that targets .NET Standard 1.3 will be compatible withapps that target .NET Framework 4.6, .NET Core 1.0, Universal Windows Platform 10.0, and any other platform that supports .NET Standard 1.3. The library will not have access to some parts of the .NET API, though. For instance, the Microsoft.NETCore.CoreCLRpackage is compatible with .NET Core but not with .NET Standard.

例如,面向 .NET Standard 1.3 的库将与面向 .NET Framework 4.6、.NET Core 1.0、通用 Windows 平台 10.0 以及支持 .NET Standard 1.3 的任何其他平台的应用程序兼容。但是,该库将无法访问 .NET API 的某些部分。例如,该 Microsoft.NETCore.CoreCLR包与 .NET Core 兼容,但与 .NET Standard 不兼容。

What is the difference between Class Library (.NET Standard) and Class Library (.NET Core)?

类库 (.NET Standard) 和类库 (.NET Core) 有什么区别?

The Package-based frameworks sectiondescribes the difference.

基于包的框架部分描述了差异。

Compatibility: Libraries that target .NET Standard will run on any .NET Standard compliant runtime, such as .NET Core, .NET Framework, Mono/Xamarin. On the other hand, libraries that target .NET Core can only run on the .NET Core runtime.

兼容性:面向 .NET Standard 的库将在任何符合 .NET Standard 的运行时上运行,例如 .NET Core、.NET Framework、Mono/Xamarin。另一方面,面向 .NET Core 的库只能在 .NET Core 运行时上运行。

API Surface Area: .NET Standard libraries come with everything in NETStandard.Librarywhereas .NET Core libraries come with everything in Microsoft.NETCore.App. The latter includes approximately 20 additional libraries, some of which we can add manually to our .NET Standard library (such as System.Threading.Thread) and some of which are not compatible with the .NET Standard (such as Microsoft.NETCore.CoreCLR).

API Surface Area:.NET Standard 库随附于NETStandard.Library.NET Core 库中,而 .NET Core 库随附于Microsoft.NETCore.App. 后者包括大约 20 个附加库,其中一些我们可以手动添加到 .NET Standard 库(例如System.Threading.Thread),而其中一些与 .NET Standard 不兼容(例如Microsoft.NETCore.CoreCLR)。

Also, .NET Core libraries specify a runtime and come with an application model. That's important, for instance, to make unit test class libraries runnable.

此外,.NET Core 库指定运行时并附带应用程序模型。例如,这对于使单元测试类库可运行很重要。

Why do both exist?

为什么两者都存在?

Ignoring libraries for a moment, the reason that .NET Standard exists is for portability; it defines a set of APIs that .NET platforms agree to implement. Any platform that implements a .NET Standard is compatible with libraries that target that .NET Standard. One of those compatible platforms is .NET Core.

暂时忽略库,.NET Standard 存在的原因是为了可移植性;它定义了一组 .NET 平台同意实现的 API。任何实现 .NET Standard 的平台都与面向该 .NET Standard 的库兼容。这些兼容平台之一是 .NET Core。

Coming back to libraries, the .NET Standard library templates exist to run on multiple runtimes (at the expense of API surface area). Obversely, the .NET Core library templates exist to access more API surface area (at the expense of compatibility) and to specify a platform against which to build an executable.

回到库,.NET Standard 库模板可以在多个运行时上运行(以 API 表面积为代价)。相反,.NET Core 库模板的存在是为了访问更多 API 表面积(以牺牲兼容性为代价)并指定一个平台来构建可执行文件。

Here is an interactive matrixthat shows which .NET Standard supports which .NET implementation(s) and how much API surface area is available.

这是一个交互式矩阵,显示哪个 .NET 标准支持哪个 .NET 实现以及有多少 API 表面积可用。

回答by user919426

A .NET Core Class Libraryis built upon the .NET Standard. If you want to implement a library that is portable to the .NET Framework, ..NET Coreand Xamarin, choose a .NET Standard Library

一个.NET核心类库是基于内置.NET标准。如果要实现可移植到.NET Framework的库,. .NET CoreXamarin,选择一个.NET 标准库

.NET Core will ultimately implement .NET Standard 2(as will Xamarinand .NET Framework)

.NET Core 最终将实现 .NET Standard 2Xamarin.NET Framework 也是如此

.NET Core, Xamarinand .NET Frameworkcan, therefore, be identified as flavoursof .NET Standard

.NET核心Xamarin.NET框架可以,因此也被认定为调味剂.NET标准

To future-proof your applications for code sharing and reuse, you would rather implement .NET Standard libraries.

为了使您的应用程序面向未来以实现代码共享和重用,您宁愿实现 .NET Standard 库。

Microsoft also recommends that you use .NET Standardinstead of Portable Class Libraries.

Microsoft 还建议您使用.NET Standard而不是Portable Class Libraries

To quote MSDN as an authoritative source, .NET Standardis intended to be One Library to Rule Them All. As pictures are worth a thousand words, the following will make things very clear:

引用 MSDN 作为权威来源,.NET Standard旨在成为一个库来统治所有。由于图片值一千字,以下内容将使事情变得非常清楚:

1. Your current application scenario (fragmented)

1、你目前的应用场景(碎片化)

Like most of us, you are probably in the situation below: (.NET Framework, Xamarin and now .NET Core flavoured applications)

像我们大多数人一样,您可能处于以下情况:(.NET Framework、Xamarin 和现在的 .NET Core 风格的应用程序)

Enter image description here

在此处输入图片说明

2. What the .NET Standard Library will enable for you (cross-framework compatibility)

2. .NET 标准库将为您提供什么(跨框架兼容性)

Implementing a .NET Standard Library allows code sharing across all these different flavours:

实现 .NET 标准库允许跨所有这些不同风格的代码共享:

One Library to Rule them All

一个图书馆来统治他们

For the impatient:

对于不耐烦的人:

  1. .NET Standardsolves the code sharing problem for .NET developers across all platforms by bringing all the APIs that you expect and love across the environments that you need: desktop applications, mobile apps & games, and cloud services:
  2. .NET Standardis a set of APIsthat all.NET platforms have to implement. This unifies the .NET platformsand prevents future fragmentation.
  3. .NET Standard 2.0will be implemented by .NET Framework, .NET Core, and Xamarin. For .NET Core, this will add many of the existing APIs that have been requested.
  4. .NET Standard 2.0includes a compatibility shim for .NET Frameworkbinaries, significantly increasing the set of libraries that you can reference from your .NET Standard libraries.
  5. .NET Standardwill replace Portable Class Libraries (PCLs)as the tooling story for building multi-platform .NET libraries.
  1. .NET Standard解决了 .NET 开发人员在所有平台上的代码共享问题,将您期望和喜爱的所有 API 引入您需要的环境:桌面应用程序、移动应用程序和游戏以及云服务:
  2. .NET标准是一组API,所有的.NET平台必须实现。这统一了 .NET 平台防止了未来的碎片化
  3. .NET Standard 2.0将由.NET Framework实现,. NET CoreXamarin. 对于.NET Core,这将添加许多已请求的现有 API。
  4. .NET Standard 2.0包含一个适用于.NET Framework二进制文件的兼容性垫片,显着增加了您可以从 .NET Standard 库中引用的库集。
  5. .NET Standard将取代可移植类库 (PCL)作为构建多平台 .NET 库的工具故事。

For a table to help understand what the highest version of .NET Standard that you can target, based on which .NET platforms you intend to run on, head over here.

如需帮助了解基于您打算在哪些 .NET 平台上运行的最高版本的 .NET Standard,您可以定位的最高版本的表格,请转到此处

Sources: MSDN: Introducing .NET Standard

来源:MSDN:介绍 .NET 标准

回答by Joe

So the short answer would be:

所以简短的回答是:

IAnimal == .NetStandard (General)
ICat == .NetCore (Less General)
IDog == .NetFramework (Specific / oldest and has the most features)

回答by Joel Coehoorn

.NETand .NET Coreare two different implementations of the .NET runtime. Both Core and Framework (but especially Framework) have different profiles that include larger or smaller (or just plain different) selections of the many APIs and assemblies Microsoft has created for .NET, depending on where they are installed and in what profile.

.NET.NET Core是 .NET 运行时的两种不同实现。Core 和 Framework(尤其是 Framework)都有不同的配置文件,包括 Microsoft 为 .NET 创建的许多 API 和程序集的更大或更小(或只是完全不同)的选择,具体取决于它们的安装位置和配置文件。

For example, there are some different APIs available in Universal Windows apps than in the "normal" Windows profile. Even on Windows, you might have the "Client" profile vs. the "Full" profile. Additionally, and there are other implementations (like Mono) that have their own sets of libraries.

例如,通用 Windows 应用程序中提供了一些与“普通”Windows 配置文件不同的 API。即使在 Windows 上,您也可能拥有“客户端”配置文件与“完整”配置文件。此外,还有其他实现(如Mono)拥有自己的库集。

.NET Standardis a specification for which sets of API libraries and assemblies must be available. An app written for .NET Standard 1.0 should be able to compile and run with any version of Framework, Core, Mono, etc., that advertises support for the .NET Standard 1.0 collection of libraries. Similar is true for .NET Standard 1.1, 1.5, 1.6, 2.0, etc. As long as the runtime provides support for the version of Standard targeted by your program, your program should run there.

.NET Standard是一种规范,必须为其提供一组 API 库和程序集。为 .NET Standard 1.0 编写的应用程序应该能够编译和运行任何版本的 Framework、Core、Mono 等,这些版本宣传了对 .NET Standard 1.0 库集合的支持。.NET Standard 1.1、1.5、1.6、2.0 等也类似。只要运行时为您的程序所针对的 Standard 版本提供支持,您的程序就应该在那里运行。

A project targeted at a version of Standard will not be able to make use of features that are not included in that revision of the standard. This doesn't mean you can't take dependencies on other assemblies, or APIs published by other vendors (i.e.: items on NuGet). But it does mean that any dependencies you take must also include support for your version of .NET Standard. .NET Standard is evolving quickly, but it's still new enough, and cares enough about some of the smaller runtime profiles, that this limitation can feel stifling. (Note a year and a half later: this is starting to change, and recent .NET Standard versions are much nicer and more full-featured).

针对某个标准版本的项目将无法使用该标准版本中未包含的功能。这并不意味着您不能依赖其他程序集或其他供应商发布的 API(即:NuGet 上的项目)。但这确实意味着您采用的任何依赖项还必须包括对您的 .NET Standard 版本的支持。.NET Standard 发展迅速,但它仍然足够新,并且足够关心一些较小的运行时配置文件,因此这种限制可能会让人感到窒息。(请注意一年半后:这开始发生变化,最近的 .NET Standard 版本更好,功能更全)。

On the other hand, an app targeted at Standard shouldbe able to be used in more deployment situations, since in theory it can run with Core, Framework, Mono, etc. For a class library project looking for wide distribution, that's an attractive promise. For a class library project used mainly for internal purposes, it may not be as much of a concern.

另一方面,针对 Standard 的应用程序应该能够在更多的部署情况下使用,因为理论上它可以运行 Core、Framework、Mono 等。对于寻求广泛分布的类库项目来说,这是一个有吸引力的承诺. 对于一个主要用于内部目的的类库项目,它可能不是那么重要。

.NET Standard can also be useful in situations where the system administrator team is wanting to move from ASP.NET on Windows to ASP.NET for .NET Core on Linux for philosophical or cost reasons, but the Development team wants to continue working against .NET Framework in Visual Studio on Windows.

在系统管理员团队出于哲学或成本原因希望从 Windows 上的 ASP.NET 迁移到 Linux 上的 .NET Core 的 ASP.NET,但开发团队希望继续针对 . NET Framework 在 Windows 上的 Visual Studio 中。

回答by bside

.NET Framework and .NET Core are both frameworks.

.NET Framework 和 .NET Core 都是框架。

.NET Standard is a standard (in other words, a specification).

.NET Standard 是一种标准(换句话说,一种规范)。

You can make an executable project (like a console application, or ASP.NET application) with .NET Framework and .NET Core, but not with .NET Standard.

您可以使用 .NET Framework 和 .NET Core 创建可执行项目(如控制台应用程序或 ASP.NET 应用程序),但不能使用 .NET Standard。

With .NET Standard you can make only a class library project that cannot be executed standalone and should be referenced by another .NET Core or .NET Framework executable project.

使用 .NET Standard,您只能创建一个不能独立执行且应由另一个 .NET Core 或 .NET Framework 可执行项目引用的类库项目。

回答by Mahbubur Rahman

Hope this will help to understand the relationship between .NET Standard API surface and other .NET platforms. Each interface represents a target framework and methods represents groups of APIs available on that target framework.

希望这有助于理解.NET Standard API 表面和其他 .NET 平台之间关系。每个接口代表一个目标框架,方法代表该目标框架上可用的 API 组。

namespace Analogy
{
  // .NET Standard

interface INetStandard10
{
    void Primitives();
    void Reflection();
    void Tasks();
    void Xml();
    void Collections();
    void Linq();
}

interface INetStandard11 : INetStandard10
{
    void ConcurrentCollections();
    void LinqParallel();
    void Compression();
    void HttpClient();
}

interface INetStandard12 : INetStandard11
{
    void ThreadingTimer();
}

interface INetStandard13 : INetStandard12
{
    //.NET Standard 1.3 specific APIs
}

// And so on ...


// .NET Framework 

interface INetFramework45 : INetStandard11
{
    void FileSystem();
    void Console();
    void ThreadPool();
    void Crypto();
    void WebSockets();
    void Process();
    void Drawing();
    void SystemWeb();
    void WPF();
    void WindowsForms();
    void WCF();
}

interface INetFramework451 : INetFramework45, INetStandard12
{
    // .NET Framework 4.5.1 specific APIs
}

interface INetFramework452 : INetFramework451, INetStandard12
{
    // .NET Framework 4.5.2 specific APIs
}

interface INetFramework46 : INetFramework452, INetStandard13
{
    // .NET Framework 4.6 specific APIs
}

interface INetFramework461 : INetFramework46, INetStandard14
{
    // .NET Framework 4.6.1 specific APIs
}

interface INetFramework462 : INetFramework461, INetStandard15
{
    // .NET Framework 4.6.2 specific APIs
}

// .NET Core
interface INetCoreApp10 : INetStandard15
{
    // TODO: .NET Core 1.0 specific APIs
}
// Windows Universal Platform
interface IWindowsUniversalPlatform : INetStandard13
{
    void GPS();
    void Xaml();
}

// Xamarin 
interface IXamarinIOS : INetStandard15
{
    void AppleAPIs();
}

interface IXamarinAndroid : INetStandard15
{
    void GoogleAPIs();
}    
// Future platform

interface ISomeFuturePlatform : INetStandard13
{
    // A future platform chooses to implement a specific .NET Standard version.
    // All libraries that target that version are instantly compatible with this new
    // platform
}
}

Source

来源

回答by Dev Kevin

Another way of explaining the difference could be with real world examples, as most of us mortals will use existing tools and frameworks (Xamarin, Unity, etc) to do the job.

另一种解释差异的方式可能是使用现实世界的例子,因为我们大多数人都会使用现有的工具和框架(Xamarin、Unity 等)来完成这项工作。

So, with .NET Framework you have all the .NET tools to work with but you can only target Windows applications (UWP, Winforms, ASP.NET, etc). Since .NET Framework is closed source there isn't much to do about it.

因此,使用 .NET Framework,您可以使用所有 .NET 工具,但您只能针对 Windows 应用程序(UWP、Winforms、ASP.NET 等)。由于 .NET Framework 是封闭源代码,因此没有太多可做的。

With .NET Core you have less tools but you can target the main Desktop Platforms (Windows, Linux, Mac). This is specially useful in ASP.NET Core applications, since you can now host Asp.net in Linux (cheaper hosting prices). Now, since .NET Core was open sourced, it's technically possible to develop libraries for other platforms. But since there aren't frameworks that support it, i don't think that's a good idea.

使用 .NET Core,您的工具较少,但您可以针对主要的桌面平台(Windows、Linux、Mac)。这在 ASP.NET Core 应用程序中特别有用,因为您现在可以在 Linux 中托管 Asp.net(托管价格更便宜)。现在,由于 .NET Core 是开源的,因此在技术上可以为其他平台开发库。但是由于没有支持它的框架,我认为这不是一个好主意。

With .NET Standard you have even less tools but you can target all/most platforms. You can target Mobile thanks to Xamarin, and you can even target Game Consoles thanks to Mono/Unity. Update: It's also possible to target web clients with UNO platform and Blazor (although both are kinda experimental right now).

使用 .NET Standard,您拥有的工具更少,但您可以针对所有/大多数平台。借助 Xamarin,您可以定位移动设备,借助 Mono/Unity,您甚至可以定位游戏机。更新:也可以使用 UNO 平台和 Blazor 来定位 Web 客户端(尽管现在两者都处于试验阶段)。

In a real world application you may need to use all of them. For example, i developed a point of sale application that had the following architecture:

在现实世界的应用程序中,您可能需要使用所有这些。例如,我开发了一个具有以下架构的销售点应用程序:

Shared both Server and Client:

共享服务器和客户端:

  • A .NET Standard library that handles the Models of my application.
  • A .NET Standard library that handles the validation of data sent by the clients.
  • 处理我的应用程序模型的 .NET Standard 库。
  • 一个 .NET Standard 库,用于处理客户端发送的数据的验证。

Since it's a .NET Standard library, it can be used in any other project (client and server).

由于它是一个 .NET Standard 库,因此可以在任何其他项目(客户端和服务器)中使用。

Also a nice advantage of having the validation on a .NET standard library since i can be sure the same validation is applied on the server and the client. Server is mandatory, while client is optional and useful to reduce traffic.

在 .NET 标准库上进行验证也是一个很好的优势,因为我可以确定在服务器和客户端上应用了相同的验证。服务器是强制性的,而客户端是可选的,可用于减少流量。

Server Side (Web API):

服务器端(Web API):

  • A .NET Standard (could be Core as well) library that handles all the database connections.

  • A .NET Core project that handles the Rest API and makes use of the database library.

  • 处理所有数据库连接的 .NET Standard(也可以是 Core)库。

  • 处理 Rest API 并使用数据库库的 .NET Core 项目。

As this is developed in .NET Core, i can host the application on a Linux server.

由于这是在 .NET Core 中开发的,因此我可以在 Linux 服务器上托管该应用程序。

Client Side (MVVM with WPF + Xamarin.Forms Android/IOS):

客户端(带有 WPF + Xamarin.Forms Android/IOS 的 MVVM):

  • A .NET Standard library that handles the client API connection.

  • A .NET Standard library that handles the ViewModels Logic. Used in all the views.

  • A .NET Framework WPF application that handles the WPF views for a windows application. Update: WPF applications can be .NET core now, although they only work on windows currently. AvaloniaUI is a good alternative for making Desktop GUI applications for other desktop platforms.

  • A .NET Standard library that handles Xamarin Forms views.

  • A Xamarin Android and Xamarin IOS project.

  • 处理客户端 API 连接的 .NET Standard 库。

  • 处理 ViewModels 逻辑的 .NET Standard 库。在所有视图中使用。

  • 一个 .NET Framework WPF 应用程序,用于处理 Windows 应用程序的 WPF 视图。更新:WPF 应用程序现在可以是 .NET 核心,尽管它们目前只能在 Windows 上运行。AvaloniaUI 是为其他桌面平台制作桌面 GUI 应用程序的不错选择。

  • 处理 Xamarin Forms 视图的 .NET Standard 库。

  • Xamarin Android 和 Xamarin IOS 项目。

So you can see that there's a big advantage here in the client side of the application, since i can reuse both .NET Standard libraries (Client API and ViewModels) and just make views with no logic for the WPF, Xamarin and IOS applications.

所以你可以看到在应用程序的客户端有一个很大的优势,因为我可以重用 .NET Standard 库(客户端 API 和 ViewModels),并且只为 WPF、Xamarin 和 IOS 应用程序创建没有逻辑的视图。

回答by sydd

.NET Standard: Think of it as a big standard library. When using this as a dependency you can only make libraries (.DLLs), not executables. A library made with .NET standard as a dependency can be added to a Xamarin.Android, a Xamarin.iOS, a .NET Core Windows/OS X/Linux project.

.NET Standard:将其视为一个大型标准库。将此用作依赖项时,您只能制作库 (.DLL),而不能制作可执行文件。可以将使用 .NET 标准作为依赖项制作的库添加到 Xamarin.Android、Xamarin.iOS、.NET Core Windows/OS X/Linux 项目。

.NET Core: Think of it as the continuation of the old .NET framework, just it's opensource and some stuff is not yet implemented and others got deprecated. It extends the .NET standard with extra functions, but it only runs on desktops. When adding this as a dependency you can make runnable applications on Windows, Linux and OS X. (Although console only for now, no GUIs). So .NET Core = .NET Standard + desktop specific stuff.

.NET Core:将其视为旧 .NET 框架的延续,只是它是开源的,有些内容尚未实现,而其他内容已弃用。它通过额外的功能扩展了 .NET 标准,但它只能在桌面上运行。将此作为依赖项添加时,您可以在 Windows、Linux 和 OS X 上创建可运行的应用程序。(尽管目前仅是控制台,没有 GUI)。所以 .NET Core = .NET Standard + 桌面特定的东西。

Also UWPuses it and the new ASP.NET Coreuses it as a dependency too.

此外UWP用它和新的ASP.NET核心使用它作为一个依赖了。

回答by ARP

.NET Standard exists mainly to improve code sharing and make the APIs available in each .NET implementation more consistent.

.NET Standard 的存在主要是为了改进代码共享并使每个 .NET 实现中可用的 API 更加一致。

While creating libraries we can have the target as .NET Standard 2.0 so that the library created would be compatible with different versions of .NET Framework including .NET Core, Mono, etc.

在创建库时,我们可以将目标设为 .NET Standard 2.0,以便创建的库与不同版本的 .NET Framework 兼容,包括 .NET Core、Mono等。

回答by toannm

Above answers may describe the best understanding about the difference between net core, net standard and net framwork so I just want to share my experience when choosing this over that.

以上答案可能描述了对网络核心、网络标准和网络框架之间差异的最佳理解,所以我只想分享我在选择它时的经验。

In the project that you need to mix between .NET Framework, .NET Core and .NET Standard. For example, at the time we build the system with .NET Core 1.0, there is no support for Window Services hosting with .net core.

在需要混合使用 .NET Framework、.NET Core 和 .NET Standard 的项目中。例如,在我们使用 .NET Core 1.0 构建系统时,不支持使用 .net Core 托管 Window Services。

The next reason is we were using Active Report which doesn't support .NET Core. So we want to build an infrastructure library that can be used for both .NET Core (asp.net core) and Windows Service and Reporting (.NET Framework) -> That's why we chose .NET Standard for this kind of library. Choosing .NET standard means you need to carefully consider every class in the library should be simple and cross .NET (core, framework, standard).

下一个原因是我们使用了不支持 .NET Core 的 Active Report。所以我们想要构建一个可以同时用于 .NET Core(asp.net core)和 Windows Service and Reporting(.NET Framework)的基础架构库 -> 这就是我们为这种库选择 .NET Standard 的原因。选择 .NET 标准意味着您需要仔细考虑库中的每个类都应该简单且跨 .NET(核心、框架、标准)。

Conclusion:

结论:

  • .NET Standard for the infrastructure library and shared common. This lib can be referenced by .NET Framework and .NET Core.
  • .NET Framework for unsupported technologies like Active Report, Window Services (now with .NET 3.0 it supports).
  • .NET Core for ASP.NET Core of course.
  • .NET Standard 用于基础结构库和共享通用。这个库可以被 .NET Framework 和 .NET Core 引用。
  • .NET Framework 用于不受支持的技术,如 Active Report、Window Services(现在支持 .NET 3.0)。
  • .NET Core 当然是 ASP.NET Core。

Microsoft just announced .NET 5: https://devblogs.microsoft.com/dotnet/introducing-net-5/

微软刚刚宣布了 .NET 5:https: //devblogs.microsoft.com/dotnet/introducing-net-5/