How to create a .NET Core library that I can reference from the .NET Core App (Web API)

I work in Visual Studio 2015 Update 3 and .NET Core 1.0. I have a web API project that is of type .NETCoreApp v1.0. When I add the .NET Core class library, it is of type .NETStandard v1.6. I can add this library to the web API project as a link, but it is not recognized when I try to add using operators.

If I create another project like .NETCoreApp, I can reference it and use classes without problems.

How can I use the .NET Core class library from my .NET Core application?

Edit / Update:

  • This only seems to be a problem for the / Intellisense editor, because despite the editor’s warnings, .NETCoreApp creates and runs by calling in the class library.
  • I run Resharper, which, as I see it, is accused of similar problems with other types of projects: I checked that I have the latest version and cleared the Resharper cache and restarted VS2105.
+4
source share
2 answers

This is a Resharper problem. At this time, Resharper (v2016.1.2) does not support .NET Core 1.0.

There are 2 possible solutions:

  • Uninstall Resharper, and also work with native intellisense Visual Studio.
  • Install Resharper 2016.2 EAP (Early Access Program). I did it and it works. Obviously, this is due to the cautions of any EAP / beta product.

Jetbrains, , .NET Core 1 EAP.

+4

, , netstandard1.X, :

  • NuGet dotnet pack NuGet. netcoreapp .
  • , :

project.json

"dependencies":{
    "MyLibrary.Core": {
        "version": "1.0.0",
        "target": "project"
    }
}

target: project dotnet NuGet-. , , .

+1

Source: https://habr.com/ru/post/1649034/


All Articles