4

I'm working in Visual Studio 2015 Update 3 and .NET Core 1.0. I have a Web API project which is of type .NETCoreApp v1.0. When I add a .NET Core class library, it is of type .NETStandard v1.6. I can add this library to the Web API project as a reference, but it is not recognised when I try to add using statements.

If I create another project of type .NETCoreApp, I can reference it and use the classes without a problem.

How do I make use of a .NET Core class library from my .NET Core App?

Edit/Update:

  1. This appears only to be an editor/Intellisense issue, because despite the editor warnings, the .NETCoreApp does build and run, calling into the class library.
  2. I am running Resharper, which I see is blamed for similar problems with other types of projects: I have checked that I have the latest version and have cleared the Resharper cache and restarted VS2105.

2 Answers 2

4

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

There are 2 possible solutions:

  1. Uninstall Resharper, and the Visual Studio native intellisense works.
  2. Install the Resharper 2016.2 EAP (Early Access Program) version. I've done this and it's working. Obviously it comes with the caveats of any EAP/beta product.

Here is a link to the Jetbrains forum post where I was told .NET Core 1 was not yet supported and pointed to the EAP version.

Sign up to request clarification or add additional context in comments.

Comments

1

Once you've built a library that targets netstandard1.X, you can either:

  • Produce a NuGet package with dotnet pack and host it locally or on NuGet. Then, install it in your netcoreapp project as any other dependency.
  • If your library and application are part of the same solution, make a local reference:

project.json

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

target: project tells dotnet to look in the current solution for the dependency, instead of using your NuGet feeds. Again, this only works if you are developing the library and application in the same solution.

2 Comments

Thanks for the useful answer, but it does not address my problem, which is the next step - once I have my .NET Core App (which is working) and added to dependency to the .NETStandard library, Visual Studio does not recognise the library - by which I mean: any attempts to reference classes in the library are highlighted as errors with the message Cannot resolve symbol 'LibraryName'. I will update my question to remove any ambiguity.
@Ettery I assumed that the problem was that the reference wasn't correct. Makes sense that you were getting a false positive from Resharper (I've run into that too).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.