0

I have a small test .NET core project which is essentially a rest interface.

The project was created as:

ASP.NET Core Web Application (.NET Framework)

I want to use an external class that comes from a module called Common

So, I right click on dependencies, Visual studio shows me all the projects in the solution and I select Common; essentially the standard step to add a dependency.

This modifies the file project.json and adds the following:

"frameworks": {
    "net462": {
        "dependencies": {
            "Common": {
                "target": "project"
            }
        }
    }
},

but, when I compile, I get the following error:

project.json(25,23): error NU1001: The dependency Common could not be resolved.

The dependency was added through the menus, the same way I'd add a dependency to any other project. Is there something totally difference in .NET Core?

Daniel
  • 9,491
  • 12
  • 50
  • 66
Thomas
  • 10,933
  • 14
  • 65
  • 136

2 Answers2

1

So, I found out that the whole thing is half baked and many others are struggling with the same problem; it just took a change in wording in my search to find that .NET core doesn't allow external dependencies unless they come under the form of a NuGet package. The IDE doesn't reflect that and it looks like the whole thing is a work in progress.

Some links that helped:

.net core 1.0 visual studio referencing external dll

How to add project reference to ASP.NET Core 1.0 MVC project

Community
  • 1
  • 1
Thomas
  • 10,933
  • 14
  • 65
  • 136
  • The tooling for .net core is still in prerelease state. Expect it to be in its final form with the release of vs2017 – Scott Chamberlain Dec 24 '16 at 23:26
  • I'll try to download the VS 2017 RC to see how it goes – Thomas Dec 25 '16 at 11:24
  • They do allow it, if the project is in the same solution. For compiled DLLs its true that you need package for VS2015 tooling. VS2017 tooling already supports the new csproj structure, which also allows to reference compiled DLLs w/o nuget package – Tseng Dec 25 '16 at 11:58
0

If you manually edit the dependencies section of project.json and add the dll name and the version, it will be picked up and be available.

So I created WebAPI project and a class library project called ClassLibrary...then ClassLibrary as a dependency on project.json of webapi project.

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.1.0",
      "type": "platform"
    },
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",    
    "ClassLibrary": "1.0.0"
  }
....}

Although I have tested this on Linux not Windows but I don't think it should be much different.

Chirdeep Tomar
  • 4,281
  • 8
  • 37
  • 66