.NET Standard v2.0


We’ve spoken about .NET Standard before. It isn’t a framework or library: it’s a set of APIs that a platform has to implement or a library has to constrain itself to in order to claim to be compliant with the standard. This allows developers to quickly check whether the code they want to run is compatible with the platform they want to run it on.

One of the benefits of .NET Standard is that it will be the end of Portable Class Libraries (PCLs), which defined the APIs you could use as the intersection of the APIs common to a set of existing platforms. We’ve found creating .NET Standard class libraries a definite improvement over PCLs and migration isn’t too hard if you’re using VS2017 (Xamarin has a handy guide). You will still be able to reference PCLs, so you don’t have to upgrade everything at once.

The .NET Standard v2.0 tooling and support is still rough around the edges. At the moment, we recommend targeting v2.0 if you’re developing an internal app – this will enable you to reference any other Standard library. Target v1.3 if you’re developing a library for external use – this will be helpful to people that haven’t updated their applications to the latest version of the Standard yet.

There’s a few gotchas to be aware of:

      • support for .Net Standard in Visual Studio 2015 is really bad
      • in VS2017, when you choose a Standard version to target, for example 1.6, it actually targets the latest revision, for example 1.6.1
        • that means building the same code today might behave differently to yesterday or tomorrow
        • this can be suppressed by adding the following to the CSProj: <NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
      • although you can reference PCL projects, it requires another CSProj hack:


        • and you will need to reference the Microsoft.NETCore.Portable.Compatibility NuGet package
      • when a .NET project references a .NET Standard NuGet package there can be conflicts with the System.xxxx dependencies due to version number mismatches
        • another CSProj hack will sort that:


      • beware of .NET 4.6.2:
        • it is compatible with .NET Standard 1.5 and below, and 2.0, but not 1.6
        • it was released before .NET Standard 2.0 was finalised and so requires a compatibility shim; this is added automatically for you, but does increase the size of your app
TAB Logo