.NET Standard over PCL Xamarin.Forms.Core project
Asked Answered
C

2

2

I'm reading that .NET Standard is now preferred over PCL class libraries to share code.

My question is should I use a .NET Standard library over a PCL for the core of a Xamarin Forms solution? Currently, it will target iOS and Android, but we are looking to Tizen for TV in the future.

Colet answered 7/11, 2017 at 15:36 Comment(0)
H
1

.NET Standard will be the future, so if you can you should get on board now.

But be aware. If you're planning on using NuGet packages you could run into the situation that a package (or library from another source) does not support .NET Standard yet. Or the other way around is true as well. There are libraries that only support .NET Standard as of now, so you should either install an older version (with all the risks that come with it) or find an alternative path.

Also note; a lot is happening now in .NET Standard (and Core for that matter) land so be prepared for bugs, rough tooling and not all platforms being supported just yet.

Hydrophobic answered 7/11, 2017 at 15:53 Comment(3)
Thanks for the comment. Its the 'bugs, rough tooling' that concerns me.Colet
I thought .Net Standard allowed fallback support for PCL's?Whortleberry
Please do tell Steve! I’m not aware of thisHydrophobic
V
4

You can also choose the best of both world by using .Net standard and the PackagetargetFallback attribute in order to be compatible with libraries not officialy compatible with it:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <PackageTargetFallback>portable-net45+win8+wpa81+wp8</PackageTargetFallback>
  <PropertyGroup>
<!...>
Venus answered 8/11, 2017 at 9:37 Comment(2)
You can also add reference to nuget packages which have target for full .net framework only.Lambency
The fallback makes things a little more palatableColet
H
1

.NET Standard will be the future, so if you can you should get on board now.

But be aware. If you're planning on using NuGet packages you could run into the situation that a package (or library from another source) does not support .NET Standard yet. Or the other way around is true as well. There are libraries that only support .NET Standard as of now, so you should either install an older version (with all the risks that come with it) or find an alternative path.

Also note; a lot is happening now in .NET Standard (and Core for that matter) land so be prepared for bugs, rough tooling and not all platforms being supported just yet.

Hydrophobic answered 7/11, 2017 at 15:53 Comment(3)
Thanks for the comment. Its the 'bugs, rough tooling' that concerns me.Colet
I thought .Net Standard allowed fallback support for PCL's?Whortleberry
Please do tell Steve! I’m not aware of thisHydrophobic

© 2022 - 2024 — McMap. All rights reserved.