0

I have multiple projects in my solution. I am trying to create build definitions for my build server. I have Core Project that have no dependencies with the following project.json:

 {
  "version": "1.0.0-*",

  "frameworks": {
    "netcoreapp1.0": {}
  },
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.1"
  }
}

I am trying to restore then build this project, but its complaining about other project that's not related to it.

Restore

enter image description here

PS C:\Program Files (x86)\TeamCity\buildAgent\work\3c13246440f9a264\src\Compas.Core> dotnet restore
log  : Restoring packages for C:\Program Files (x86)\TeamCity\buildAgent\work\3c13246440f9a264\src\Compas.Core\project.json...
log  : Writing lock file to disk. Path: C:\Program Files (x86)\TeamCity\buildAgent\work\3c13246440f9a264\src\Compas.Core\project.lock.json
log  : C:\Program Files (x86)\TeamCity\buildAgent\work\3c13246440f9a264\src\Compas.Core\project.json
log  : Restore completed in 2071ms.

Build

PS C:\Program Files (x86)\TeamCity\buildAgent\work\e5c291e45d6e2691\src\Compas.Core> dotnet build
Project Microsoft.Extensions.Caching.Abstractions does not have a lock file. Please run "dotnet restore" to generate a new lock file.
Project Microsoft.Extensions.Caching.Abstractions does not have a lock file. Please run "dotnet restore" to generate a new lock file.

I have "Microsoft.Extensions.Caching.Abstractions" in my solution, but why build Core would need that lock file there.

Hussein Salman
  • 7,806
  • 15
  • 60
  • 98
  • Try deleting file C:\Program Files (x86)\TeamCity\buildAgent\work\e5c291e45d6e2691\src\Compas.Core\project.lock.json if its present and rerun restore. – Pankaj Kapare Feb 28 '17 at 21:49
  • I already did that – Hussein Salman Feb 28 '17 at 21:51
  • Ok. One more trick you may try is : Add some random dependency in project.json which you can remove later that will force to write lock file. – Pankaj Kapare Feb 28 '17 at 21:53
  • Its already creating the lock file for the Compas.Core project but its complaining about other project. – Hussein Salman Feb 28 '17 at 21:58
  • 1
    If you have project references you need to restore all projects. The easiest way to do it is to go to the solution/repo root and run `dotnet restore` there. – Pawel Feb 28 '17 at 22:08
  • @Pawl I am creating build definitions for the build server for CI, I guess the it wouldn't be efficient to run the restore on the solution in this case... – Hussein Salman Mar 01 '17 at 04:18

1 Answers1

2

Your project depends on Microsoft.EntityFrameworkCore.SqlServer which in turn depends on Microsoft.Extensions.Caching.Abstractions (not directly, but later in the tree). Since you have that project in your solution - probably because you have a reference in your global.json - it will try and use that project rather than the NuGet package.

However, for the project reference to work, it needs a project.lock.json and therefore it complains about restoring the project's packages.

Either remove the project from your solution (I wonder why it's there in the first place) or make sure its packages have been restored.

Henk Mollema
  • 44,194
  • 12
  • 93
  • 104