Question: ASP.NET 5 Class Libraries (Package) and target frameworks

Question

ASP.NET 5 Class Libraries (Package) and target frameworks

Answers 1
Added at 2016-01-08 15:01
Tags
Question

In the simple case that I create a new Solution and then add a new ASP.NET 5 web app and a Class Library (Package) to the solution.

There are the default framework references for each project:
Web App: dnxcore50 and dnx451
Class Library (Package): net451, dotnet5.4

If I try to add a reference from the web app to the class library there are issues. It adds successfully, but from the web app when I go to create a new instance of a class from the library it can't find anything. I believe this is because the class library must support the frameworks in the project.

Do I really need to add all 4 frameworks to my class library?

  "frameworks": {
    "dnxcore50": { },
    "dnx451": { },
    "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"
      }
    }
  }

Shouldn't I be able to only use dnxcore50 and dnx451 in the class library and still use the System namespace? As soon as I remove net451 and dotnet5.4 I get a bunch of errors in regards to the System namespace.

Answers
nr: #1 dodano: 2016-01-08 15:01

In your class library, remove dnxcore50 and dnx451

"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"
    }
  }
}
Source Show
◀ Wstecz