.Net Core、Portable、Standard、Compact、UWP 和 PCL 之间的区别? [英] Difference between .Net Core, Portable, Standard, Compact, UWP, and PCL?

查看:30
本文介绍了.Net Core、Portable、Standard、Compact、UWP 和 PCL 之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

听说过

  • .Net 核心
  • .Net 便携版
  • .Net 标准
  • .Net 精简版
  • 通用 Windows 平台
  • 便携式类库

所有这些都向我解释为完整 .Net 的一个子集,允许您面向多个平台".所以我的问题是

All of these were explained to me as "a subset of the full .Net that allows you to target multiple platforms". So my questions are

  1. 有什么不同!?
  2. 如果我想编写一个可供尽可能多的受众使用的库,我需要使用其中的哪一个(或多个)?

<小时>

(我的具体情况:我有一个一个库针对.Net 2.0、.Net 4.5和UWP.针对UWP需要创建一个新的VS项目并链接所有现有文件,这是一个巨大的痛苦.现在有人告诉我它不适用于PCL,并且从声音对于 .Net Standard,我必须再次这样做!?)


(My specific situation: I have a library that targets .Net 2.0, .Net 4.5, and UWP. Targeting UWP required creating a new VS project and linking all the existing files, which is a huge pain. Now someone is telling me it doesn't work for PCL, and from the sound of it I have to do it AGAIN for .Net Standard!?)

推荐答案

我先回答你的第二个问题:

I'll answer your second question first:

我有一个面向 .Net 2.0、.Net 4.5 和 UWP 的库.针对 UWP 需要创建一个新的 VS 项目并链接所有现有文件,这是一个巨大的痛苦.现在有人告诉我它不适用于 PCL,从它的声音来看,我必须为 .Net Standard 再次这样做!?)

I have a library that targets .Net 2.0, .Net 4.5, and UWP. Targeting UWP required creating a new VS project and linking all the existing files, which is a huge pain. Now someone is telling me it doesn't work for PCL, and from the sound of it I have to do it AGAIN for .Net Standard!?)

如果我想编写一个可供尽可能多的受众使用的库,我需要使用其中的哪一个(或多个)?

If I want to write a library that's usable to as large an audience as possible, which one (or more than one) of these do I need to use?

简短回答:您应该针对 netstandard.使用 最低版本您需要的 API.您可以使用 API 端口 之类的工具来检查现有项目与给定netstandard 版本的兼容性.

Short answer: you should target netstandard. Use the lowest version that has all the APIs you need. You can use a tool like API Port to check your existing project for compatibility with a given netstandard version.

不幸的是,这种方法会留下旧平台,在您的情况下,是 .NET 2.0.如果需要维护 .NET 2.0 支持,那么您将需要一个单独的项目(带有链接文件)来构建单独的 .NET 2.0 程序集.

Unfortunately, this approach will leave behind older platforms, in your case, .NET 2.0. If maintaining .NET 2.0 support is necessary, then you'll need a separate project (with linked files) to build a separate .NET 2.0 assembly.

关于细节...

有什么不同!?

  • .Net Standard (netstandard) - 这是新的跨平台 BCL API.这是一个标准"从某种意义上说,它只是一个 API 定义而不是一个实现.这个想法是你可以将你的库编译成这个 API 的(一个版本),它可以在支持该版本的任何平台上运行.
  • .Net Core - 您可以将其视为 netstandard 的参考实现(有一些额外的位).它是该 API 的跨平台实现.UI 和其他框架可能基于它构建,但目前它唯一确定的立足点是作为 ASP.NET Core 的首选平台.[旁注:由于历史原因,.NET Core"与 netcore NuGet 目标 完全不同;当您处于 NuGet 上下文中时,netcore表示Windows 8/8.1/10"].
  • .Net Portable可移植类库 - 可移植类库 (PCL) 是提供跨平台 API 的最小公分母方法.它们涵盖了范围广泛的目标平台,但它们不完整且不面向未来.它们基本上已被 netstandard 取代.
  • .Net Compact - 这是一个完全不同的 .NET 框架,具有自己独特的 API.它与任何其他框架、PCL 或 netstandard 版本完全不兼容;因此,它比任何其他平台更难支持.但是,它仍用于内存受限的设备.
  • 通用 Windows 平台 - 这是 Windows Phone 和桌面之间 API 的 Win10 时代合并,允许为两个平台编写 Windows 应用商店应用程序/库.这基本上已被 netstandard 取代.
    • .Net Standard (netstandard) - this is the new cross-platform BCL API. It's a "standard" in the sense that it's just an API definition and not an implementation. The idea is that you can compile your library to (a version of) this API and it will run on any platform that supports that version.
    • .Net Core - you can think of this as a reference implementation of netstandard (with a few extra bits). It is a cross-platform implementation of that API. It is possible that UIs and other frameworks may build on it, but for now its only sure foothold is acting as the platform of choice for ASP.NET Core. [Side note: for historical reasons, ".NET Core" is completely different than the netcore NuGet target; when you're in a NuGet context, netcore means "Windows 8/8.1/10"].
    • .Net Portable and Portable Class Libraries - Portable Class Libraries (PCLs) are a least-common-denominator approach to providing a cross-platform API. They cover a wide range of target platforms, but they are incomplete and not future-proof. They have essentially been replaced by netstandard.
    • .Net Compact - This is a completely different .NET framework with its own unique API. It is completely incompatible with any other framework, PCL, or netstandard version; as such, it is much more difficult to support than any other platform. However, it is still used on devices with tight memory constraints.
    • Universal Windows Platform - This was a Win10-era merging of the API between Windows Phone and desktop, allowing Windows Store apps/libraries to be written for both platforms. This has essentially been replaced by netstandard.
    • 这篇关于.Net Core、Portable、Standard、Compact、UWP 和 PCL 之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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