Search code examples
.netvisual-studio-2015dependency-managementportable-class-library

VS2015 is unable to reference project dependencies


I am trying to reference a class library project within the solution to a simple console application. But it seems like Visual Studio wont let me.

I have searched around, and i keep finding guides on how to add dependencies, but no-one seems to have the same issue, as the dependencies has been added to the project.

Project

If you look at the image above, you will see that this is just a plain project, brand new Console Application with a Class Library, nothing edited except the dependencies, and a extra line trying to reference Class1.cs from the Class Library.

I get a intellisense message suggesting me to add the reference to the project, if i click it, nothing happens.

As you can also see, i tried to add the using statement manually, without any success. It just says "Cannot resolve symbol ClassLibrary1"

Dependency

Image showing that i added the dependecy for the project.

Project reference

Image showing that i have tried adding the project reference

Now, All this beeing said. The same thing happens to the project i am suppose to work on, but on that project, i just get the message "Cannot add project X as a reference" when trying to add the class library as a reference. But i can add the Dependency, but still, it basically gives me the same error as this clean project does.

I am using Visual Studio 2015 - Enterprise.

Class Library Project.json: 
    {
      "version": "1.0.0-*",
      "description": "ClassLibrary1 Class Library",
      "authors": [ "Tweek" ],
      "tags": [ "" ],
      "projectUrl": "",
      "licenseUrl": "",

      "dependencies": {
        "System.Collections": "4.0.10-beta-23019",
        "System.Linq": "4.0.0-beta-23019",
        "System.Threading": "4.0.10-beta-23019",
        "System.Runtime": "4.0.10-beta-23019",
        "Microsoft.CSharp": "4.0.0-beta-23019"
      },

      "frameworks": {
        "dotnet": { }
      }
    }

ConsoleApp1 Project.json after editing as suggested in one of the answers:

    {
  "version": "1.0.0-*",
  "description": "ConsoleApp1 Console Application",
  "authors": [ "Tweek" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "dependencies": {
  },

  "commands": {
    "ConsoleApp1": "ConsoleApp1"
  },

  "frameworks": {
    "dnx451": {
      "dependencies": {
        "ClassLibrary1": "1.0.0-*"
      }
    }
  }
}

Any help is greatly appreciated!


Solution

  • Found the solution to the problem -

    You have to use the "Class library" or "Class Library (portable)" under "Windows"

    Project