0

I'm doing a Network library (https://github.com/Eastrall/Ether.Network) for now targeting the .NET Core framework, but I want support both .NET Core and .NET Framework (4.*)

I heard about adding some lines on the project.json is this a good solution?

Can someone help me with this? Thanks

2
  • too vague, .net core is much more limited in scope than .NET framework I don't see how this is possible. Commented Nov 10, 2016 at 14:11
  • 1
    So I can't deploy my library on NuGet for .NET Core and .NET Framework? Commented Nov 10, 2016 at 14:18

1 Answer 1

2

Yes, modifying project.json is what you need. It should look like:

{
  "version": "1.0.0",

  "dependencies": {
    "NETStandard.Library": "1.6.0"
  },

  "frameworks": {
    "netstandard1.3": {
      "imports": "dnxcore50"
    }
  }
}

Here is a scheme of mapping the .NET Platform Standard to platforms of interest from the official documentation:

enter image description here

A few quick notes:

  • If a library targets .NET Platform Standard version 1.3, it can only run on .NET Framework 4.6 or later, .NET Core, Universal Windows Platform 10 (UWP), and Mono/Xamarin platforms.
  • If a library targets .NET Platform Standard version 1.3, it can consume libraries from all previous .NET Platform Standard versions (1.2, 1.1, 1.0).
  • The earliest .NET Framework to support a .NET Platform Standard version is .NET Framework 4.5. This is because the new portable API surface area (aka System.Runtime based surface area) that is used as the foundation for the .NET Platform Standard only became available in that version of .NET Framework. Targeting .NET Framework <= 4.0 requires multi-targeting.

For further details it is recommended to check out the official documentation.

Sign up to request clarification or add additional context in comments.

3 Comments

it's probably worth adding that it's best to avoid using netstandard 1.5 or 1.6, as they won't be compatible with netstandard 2.0, which it's available. Netstandard 1.4 or earlier will be compatible with netstandard 2.0, so it's a good choice for making portable libraries now. blogs.msdn.microsoft.com/dotnet/2016/09/26/…
@Ziv That comment is outdated, see .NET Framework 4.6.1 supporting .NET Standard 2.0. Though it's still preferable to avoid .Net Standard 1.5 and 1.6, because members specific to them won'will fail on .Net 4.6.1 at runtime.
Thank you! That's what I needed!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.