visual-studio.net-4.5asp.net5

Convert a C# Library to Net.Core


As .NET Core is getting nearer, I will start to convert our Library to NET-Core, so that it could be used from our old Code (Net 4.5) and Net Core! But for me it is not clear what Type should my Library be. I've no "Net-Core" Project Type in VS2015! Do I need to use old school "PCL" Library? Or how do I do it?


Solution

  • But for me it is not clear what Type should my Library be. I've no "Net-Core" Project Type in VS2015! Do I need to use old school "PCL" Library? Or how do I do it?

    Use the Web > Class Library (Package) type.

    Class Library (Package)

    The screenshot is from Visual Studio Community 2015 Update 2 with ASP.NET 5 RC1 installed. Its project.json targets two frameworks: .NET 4.5.1 and .NET 5.4 (renamed to .NET Core.)

    {
      // other properties deleted for clarity
    
      "frameworks": {
        "net451": { },
        "dotnet5.4": {
          "dependencies": {
            "Microsoft.CSharp": "4.0.1-beta-23516",
            "System.Collections": "4.0.11-beta-23516",
            "System.Linq": "4.0.1-beta-23516",
            "System.Runtime": "4.0.21-beta-23516",
            "System.Threading": "4.0.11-beta-23516"
          }
        }
      }
    }
    

    Tip. When you're upgrading your class library, run the .NET Portability Analyser on the existing code. It will show the classes & members that must change.