Jochen Kühner
Jochen Kühner

Reputation: 1411

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?

Upvotes: 6

Views: 5126

Answers (2)

Shaun Luttin
Shaun Luttin

Reputation: 141662

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.

  • File > New > Project
  • Web > Class Library (Package)

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.

Upvotes: 5

Bruno Garcia
Bruno Garcia

Reputation: 6408

At this point, at RC1, you can use the ASP.NET 5 stuff, with DNX. There's project type Class Library, with project extension xproj.

Keep in mind a lot is changing, including DNX will be retired in favor of dotnet cli, and more importantly the renaming of ASP.NET 5 to ASP.NET Core 1.0

You can target dnxcore5 (or one of those new monikers) when using those project templates.

Answering your comment:

When you install ASP.NET 5, new Visual Studio project templates are added for you. For Web projects. Class Libraries and Console application. All using project.json.

Their roadmap has RC2 date as TBD since they announced the renaming of things. No dates yet.

Upvotes: 3

Related Questions