1
votes

I am converting xamarin forms pcl to .net standard. In the project I use skia sharp and azure mobileservices.

My understanding was that if I reference these libraries in the .net standard class library and then add a reference to this .net standard class library in my android/ios/uwp projects all would be fine.

However it seems that I need to add the nuget packages for skiasharp and azure mobileservices to each project (android/ios/uwp). Is this indeed the case? if so, how is this better than using PCL?

I got the android project working, but I needed to add all the nuget packages to the android project. I got the uwp project working without any nuget packages, which confuses me even further.

1

1 Answers

1
votes

Using PCL and .NET Standard are basically the same - both are just API contracts or a subset of the full .NET Framework. But there is a MAJOR advantage to .NET Standard: .NET Standard has far more APIs - especially if you are using 1.3+ (netstandard1.3 has the System.IO APIs which aren't available in PCL).

With regards to NuGets, you typically still need to reference the NuGet package in all the app projects because some platforms have different implementations to take advantage of platform features. Think of .NET Standard as a subset of all the platform APIs - this is why SkiaSharp works just fine for some platforms. However, Android and iOS have a different implementation to take advantage of platform features.

Although you aren't doing Android development directly (since you are using Xamarin.Forms) you wouldn't have noticed something. If you JUST include the .NET Standard package, you get the basic SkiaSharp that can, for example, convert between a Xamarin.Forms color and a SkiaSharp color. However as a result of including the package in the android app, you can additionally convert from an Android color to a SkiaSharp color.

Personally, I always include all the NuGets into the app projects just to be safe.

Here are some docs that may help you: https://docs.microsoft.com/en-us/dotnet/standard/net-standard