Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between .NET Core and PCLs?

I was writing up the supported platforms for my PCL recently, one of which is other PCLs. I was confused if my library (which targets .NET Framework 4.5 and Windows/Phone 8.1) can be used in .NET Core projects as well.

As I understand it, PCLs allow you to share code across multiple platforms without recompilation, while .NET Core does that as well. The only difference is that .NET Core targets a few more platforms, i.e. OS X and Linux, and is open source.

So essentially, I don't see how .NET Core is any different than Microsoft rebranding the PCL and saying "PAY ATTENTION we're going open source and targeting non-Windows platforms!"

So the bottom line is, are PCLs compatible with .NET Core, and vice versa? What's the difference between them?

like image 332
James Ko Avatar asked Aug 04 '15 15:08

James Ko


People also ask

Is there a difference between .NET and .NET Core?

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.

Which is better .NET Core or .NET Framework?

NET and ASP.NET Core are your best options. The high-performance server runtime for Windows Server and Linux makes ASP.NET Core a top performing web framework on TechEmpower benchmarks. Performance and scalability are especially relevant for microservices architectures, where hundreds of microservices may be running.

Is mono same as .NET Core?

What is the difference between . NET Core and Mono? NET Core, which natively only allows you to build console apps and web applications, mono allows you to build many application types available in . NET Framework, including GUI-enabled desktop apps.

Is .NET Core replace .NET Framework?

With the planned release of a unified platform in 2020, . NET Core will replace . NET Framework. You will be able to use it to target Windows, Linux, macOS, iOS, Android, tvOS, watchOS, WebAssembly, and more.


1 Answers

There is a beautiful article series about it which solved my questions around it ...

https://oren.codes/2015/06/16/demystifying-pcls-net-core-dnx-and-uwp-redux/ https://oren.codes/2015/07/29/targeting-net-core/

.Net Core has all his libraries (e.g. System.IO) in separate NuGet packages (each of them available for the SDKs DNX, UWP and .Net 4.6). Third party libraries target dnxcore50 (DNX) or uap10.0 (UWP) if they access the platform natively or rely on their features. If they do not access the platform but only rely on other packages, they should target dotnet.

dotnet effectively means: I am compatible with any platform which satisfy my dependencies (your library XYZ "dotnet" which uses System.Reflection dnxcore5+net45 could not be used by a UWP uap10.0 app). This effectively ends the combinatoric nightmare of the platforms. The previous target combination dnxcore5+net45 created an intersection between the platforms libraries and each addition would make the situation even worse. dotnet on the other side does not restrict the library on a target but instead forwards this restriction decision to its dependencies (where suddenly new restrictions like the famous unicorn platform can show up).

Therefore as a library author you can target dotnet if you just need other libraries.

Answering your question:

  • Your PCL is compatible with .Net Core style environments like DNX and UWP if you add the target dotnet, dnxcore50 or uap10.0 depending on the need of your library (see Owen's article for same basic compatibility with the contract Profile 259).
  • .Net Core is much more than a set of PCLed libraries. It is a new CLR, a new organized framework (packaged in small parts) and the infrastructure for new .Net SDKs (DNX, UWP, and whatever comes next). The term ".Net Core" targets both, the base class library "CoreFx" and the CLR "CoreCLR". But the real platforms are in reality DNX (by ASP.Net team) and UWP (by Windows team).

All of that answer is my current understanding of the .Net Core library situation. It is work in progress, and like mentioned in the posts, not yet public documented.

NOTE DEC 2016: Be aware, dotnet as the predecessor to netstandard1.x has changed in its concept starting with netstandard2.x (.NET Core 2.0; ~JUN 2017). Beginning with netstandard2.0 there will be one common contract (the netstandard.dll) which all platforms (.NET Core, .NET Framework, Xamarin, Mono, Unity3D) implement. This contract will be extended over time and the platform have to either drop support for the latest standard, throw NotImplementedException or implement it.

like image 192
Thomas Avatar answered Oct 08 '22 06:10

Thomas