.net-core-rc1

Why does the .NetCore Class Library reference .NetStandard?


In VS2015 > New Project > .Net Core, there is a template for "Class Library (.NET Core)"

It wasn't until I tried to reference this library in a .NET Core Web API program, that I realized that the Class Library template is referencing .NETStandard v1.6. And my .NET Core API porject won't take it as a reference. I was trying to avoid building the library as a nuget package.

Any ideas on why a Core template isn't referencing core? Any ideas on quick workarounds?

Update: Opened a new "Class Library (.NET Core)", before first build I changed frameworks in project.json to

"netcoreapp1.0": { "imports": [ "dotnet5.6", "portable-net45+win8" ]

Then I created, in a different VS instance, a new "ASP.NET Core Web Application (.NET Core)".

I tried to add a reference to the .dll file for the new class library, now in a netcoreapp1.0 folder and I still get the same error:

.NET Core Projects only support referencing .NET framework assemblies in this release.


Solution

  • How to fix your problem

    I was trying to avoid building the library as a nuget package.

    Any ideas on why a Core template isn't referencing core? Any ideas on quick workarounds?

    When you try to add the .dll as a reference for the API, your error message should say somewhere that you need to create a package in order to use that class library. It is described in the documentation.

    However if you do not want to bother to make a package, for example if your class library is used now only in your API project, the easiest way is to build your class library as a Project of your Solution where the API lives. To do so, copy-paste your code in the Solution folder and include it as a project.

    Some explanations about the version and frameworks

    The Core template (I guess you are talking about the .NET Core API) should create a project.json with

      "frameworks": {
        "netcoreapp1.0": {
             "imports": [
                 "dotnet5.6",
                 "portable-net45+win8"
           ]
        }
      }
    

    Let's see what the lines are responsible for:

    That being said, I am more than welcome for comments!