Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between .Net Core, Portable, Standard, Compact, UWP, and PCL?

I've heard of

  • .Net Core
  • .Net Portable
  • .Net Standard
  • .Net Compact
  • Universal Windows Platform
  • Portable Class Libraries

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. What's the difference!?
  2. 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?

(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!?)

like image 961
BlueRaja - Danny Pflughoeft Avatar asked Nov 09 '16 19:11

BlueRaja - Danny Pflughoeft


People also ask

What is the difference between .NET Standard and PCL portable class libraries?

NET Standard is platform-agnostic, it can run anywhere, on Windows, Mac, Linux and so on. PCLs can also run cross-platform, but they have a more limited reach. PCLs can only target a limited set of platforms.

Is UWP irrelevant for .NET core?

UWP does NOT run on the . NET Core App runtime like a . NET Console does, if that makes sense.

What is net Core vs net Framework?

NET Framework to create Windows desktop and server-based applications. This includes ASP.NET web applications. On the other hand, . NET Core is used to create server applications that run on Windows, Linux and Mac.

What is net Core used for?

ASP.NET Core is a cross-platform, high-performance, open-source framework for building modern, cloud-enabled, Internet-connected apps. With ASP.NET Core, you can: Build web apps and services, Internet of Things (IoT) apps, and mobile backends. Use your favorite development tools on Windows, macOS, and Linux.


1 Answers

I'll answer your second question first:

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?

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.

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.

On to the details...

What's the difference!?

  • .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.
like image 172
Stephen Cleary Avatar answered Sep 23 '22 16:09

Stephen Cleary