.NET (standard, Core and Framework): Developing Cross Platform Applications

I have searched SO, but I find a lot of answers but not targeting my questions:

AS the definitions say:

  • .NET Framework 4.6 is a full framework for everything related to .NET, but lacks libraries & runtime optimized for multi-platform (Windows, Linux and Mac) and cloud deployments
  • .NET Core on the other hand is a subset of .NET Framework 4.6 which is mainly optimized for multi-platform and cloud deployments
  • NET standard: a 'standard' set of APIs rather than a platform. So basically you don't care about platforms, just the standard (version 1.3, 1.6 ...) and your code will work on all platforms that support it.
  • In order to develop cross platform applications, I intend to create ASP.NET core applications (.NET) which might reference other class libraries that might use:

  • .NET Standard
  • .NET Core
  • I assume that if I use any(standard or Core) my application will still support other OS.

    In Some cases, I see people using traditional .NET Framework With .NET Standard in class library?

  • In this case, Is the application still cross platform when using .NET Framework?
  • When Should I mix and use a combination (Standard , Core, NET)?
  • What is the best practices in using and mixing between frameworks?
  • How to avoid any conflicts and build failures?
  • For instance, let's say I have a class library that has the project.json:

     "dependencies": {
        "Microsoft.Extensions.Caching.Abstractions": "1.0.0",
        "Microsoft.Extensions.Options": "1.0.0",
        "StackExchange.Redis.StrongName": "1.1.608",
        "NETStandard.Library": "1.6.0"
      },
      "frameworks": {
        "netstandard1.5": { }
      }
    

    How is the dependency different from framework? and how is the project resolving the assemblies since the Standard Library is just a specification.


    In this case, Is the application still cross platform when using .NET Framework?

    Not really, a .Net Framework application won't run on .Net Core. But it might run on mono, which is available on Linux and Mac OS.

    When Should I mix and use a combination (Standard , Core, NET)?

    You should use .Net Standard for your libraries, if you can (ie as long as they don't have any framework-specific dependencies).

    You use .Net Framework for your applications if they have .Net Framework-specific dependencies or if the application can be Windows-only.

    You use .Net Core for your application if it needs to be cross-platform, or if you want to use newest APIs. (.Net Core generally updates faster then .Net Framework and also has preview versions.)

    What is the best practices in using and mixing between frameworks?

    I don't understand the question. You can't mix .Net Framework and .Net Core in the same application.

    How to avoid any conflicts and build failures?

    I don't think that's an answerable question, though I can offer some obvious advice:

  • Read and follow the documentation.
  • Don't use unstable technologies. (Keep in mind .Net Core tooling is currently still in preview.)
  • EDIT:

    How is the dependency different from framework?

    "frameworks": { "netstandard1.5": { } } means that the library is a .Net Standard 1.5 library and decides which frameworks it can be used from.

    "dependencies": { "NETStandard.Library": "1.6.0" } actually brings in the packages that are part of .Net Standard Library. It also means that the library can access all of .Net Standard Library, not just some subset of it.

    How is the project resolving the assemblies since the Standard Library is just a specification?

    The packages that NETStandard.Library depends on are more than just a specification. For example, the package System.IO.Compression.ZipFile contains:

  • reference assemblies used for compilation (ie the specification)
  • implementation of ZipFile for .Net Framework 4.6, which just forwards to the System.IO.Compression.FileSystem framework assembly
  • implementation for .Net Core which actually implements ZipFile
  • (To look inside packages yourself, I recommend NuGetPackageExplorer.)

    链接地址: http://www.djcxy.com/p/81890.html

    上一篇: Visual Studio新项目向导:.NET Core vs .NET标准库?

    下一篇: .NET(标准,核心和框架):开发跨平台应用程序