In previous post, we have learned how to create simple .Net
Standard library using VS 2015 and VS 2017 RC. Today we will discuss how .Net
Standard is different from PCL and how .Net Standard is versioned.
PCL is an afterthought. So, individual platforms such as
.Net Core, Xamarin etc. is built and developed against their base libraries.
When code reuse is needed, we use PCL which takes an intersection of the base
libraries of individual platforms.
This has lots of issues like what happens when tomorrow your
PCL needs to support a new platform?
You create a new PCL profile and take again intersection of
all the platforms involved. This means recreate the library again with a different profile. Hence a new PCL will be created with intersection of the platforms and hence lot of changes needed in the already written library as the base library is now further reduced in terms of APIs.
On the other hand, .Net Standard is a before thought.
Platforms in .Net develop against .Net Standard. So tomorrow your .Net Standard
library can be consumed by any new platform as long as that platform supports
that version or a higher version of .Net Standard.
Let’s now see more on .Net Standard versions. Below are 2
rules.
Higher the version, Larger is the API set.
Lower the version, more number of platforms supports that
version of .Net Standard.
Currently they are versioned as 1.1, 1.2, 1.3, 1.4, 1.5,
1.6, 2.0. So, version 1.2 has all APIs introduced in 1.2 version along with all
APIs from 1.0. Similarly, 2.0 has all APIs from 1.6 plus APIs introduced in
2.0.
1.6 is the stable version and 2.0 is the latest release
candidate as of writing this article.
Mapping PCL
Profiles to .Net Standard:
As we know PCL has different profile numbers. For example,
if PCL supports .NET Framework 4.5, Windows 8 then its profile 7.
Based on the profile number we can convert a PCL to a
specific version of .Net Standard.
PCL Profile
|
.NET Standard
|
PCL Platforms
|
7
|
1.1
|
.NET Framework 4.5, Windows 8
|
31
|
1.0
|
Windows 8.1, Windows Phone Silverlight 8.1
|
32
|
1.2
|
Windows 8.1, Windows Phone 8.1
|
44
|
1.2
|
.NET Framework 4.5.1, Windows 8.1
|
49
|
1.0
|
.NET Framework 4.5, Windows Phone Silverlight 8
|
78
|
1.0
|
.NET Framework 4.5, Windows 8, Windows Phone Silverlight 8
|
84
|
1.0
|
Windows Phone 8.1, Windows Phone Silverlight 8.1
|
111
|
1.1
|
.NET Framework 4.5, Windows 8, Windows Phone 8.1
|
151
|
1.2
|
.NET Framework 4.5.1, Windows 8.1, Windows Phone 8.1
|
157
|
1.0
|
Windows 8.1, Windows Phone 8.1, Windows Phone Silverlight 8.1
|
259
|
1.0
|
.NET Framework 4.5, Windows 8, Windows Phone 8.1, Windows Phone
Silverlight 8
|
So, if your PCL is of profile 151, then you can convert it
to support .Net Standard 1.2.