Natan
Natan

Reputation: 4958

How do I reference a local csproj in another folder using project.json?

Using VS2015 RC, I created a "Class Library (Package)" project and added a dependency, and it was downloaded from nuget:

"frameworks": {
    "net45": {
        "dependencies": {
            "LibraryX": "1.0.0-*",
        }
    }
}

I then cloned the package source to my disk (located at D:\LibraryX\LibraryX.csproj, a different folder) and now I want my new project to take dependency on that source instead of the nuget package.

I built the source, ran dnu wrap LibraryX which created D:\LibraryX\wrap\LibraryX\project.json and added a global.json to my solution folder as:

{
    "sources": ["D:/LibraryX"]
}

Still, LibraryX is always loaded from nuget. What do I need to do to make dnu see the source as a dependency and use that instead of nuget?

And how do I diagnose this? dnu list -a only tells me it's getting the reference from the nuget packages folder, but doesn't tell me where it looked for the file before choosing that.

This feature was demonstrated on stage at Build 2015, but I'm not sure what I'm missing here.

Upvotes: 4

Views: 1174

Answers (1)

Natan
Natan

Reputation: 4958

Ok, got it working. It was just a small detail:

global.json changed it's format in the latest version from sources to projects, and the path it references must contain the folders with xproj files. That is, you need to reference the "wrap" folder, or move those folders somewhere else where they keep the correct structure.

This worked:

{
    "projects": ["D:/LibraryX/wrap"]
}

Another thing: you still need to add the project to your solution to edit the files. The project.json is only to allow dnu to find the dependency. VisualStudio then uses xproj for tooling.

Upvotes: 2

Related Questions