Chris Kdon
Chris Kdon

Reputation: 916

.Net Core 1.0 Relative Project Dependencies Not Found

I have the project structure:

/src
  - common
    - common-x
      + project.json
  - module-a
    - project-a
      + project.json
    - project-a-tests
      + project.json
    + global.json

I'm trying to include the common-x project using relative file paths in the global.json file.

The global.json file in the module-a directory is as follows:

{
  "projects": [
    "project-a",
    "project-a-tests",
    "../common/common-x"
  ]
}

and the project.json file in project-a is

{
  // Default config options are also in this...

  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
    "common-x": {
      "target": "project"
    }
  }
}

project-a-tests has no problem referencing project-a since they are in the same directory, but project-a can't find the common-x project. I receive a "Unable to resolve ..." error from dotnet restore.

I have tried using absolute paths but that doesn't work either. The closest solution so far is to use symlinks but that is not preferable.

Note: This is all being run on Ubuntu 16.04.

Upvotes: 0

Views: 243

Answers (1)

Ignas
Ignas

Reputation: 4338

You should only need to specify top level folders in your global.json file, since sub-folders will be scanned automatically. Global.json reference.

So your global.json should look like this.

{
    "projects": [ "src" ]
}

If you are still getting any dependencies issues that might related to compatibility problems between projects/modules, however I would need to see the exact output you are getting to troubleshoot that.

UPDATE

A few tips that might be useful:

  • Delete old project.json.lock files
  • Add a .sln solution file if you don't have one created.

UPDATE 2

As per your comment, the working solution was to move global.json into src folder, and list your top-level folders in the projects array.

Upvotes: 1

Related Questions