dotnet restore fails to resolve local dependencies with a certain folder structure
See original GitHub issueSteps to reproduce
-
Create folder
testlib
andtestapp
under the same directory -
Inside testlib run
dotnet new
-
Inside project.json change the frameworks from
netcoreapp1.0
tonetstandard1.5
-
Create folder
src
inside testlib -
Move Program.cs and project.json inside src
-
Create global.json (not inside src) with contents
{ "projects": ["src"] }
-
Inside testlib run
dotnet restore
-
Inside testlib/src run
dotnet build
-
Now inside testapp run
dotnet new
-
Create global.json with contents
{ "projects": [".", "../testlib"] }
-
Inside project.json add testlib as a dependency
"testlib": { "target": "project", "version": "1.0.0" }
-
Now run
dotnet restore
Directory structure should look like
testlib
global.json
/src
/bin
/obj
Program.cs
project.json
project.lock.json
testapp
global.json
Program.cs
project.json
This also might be related to dotnet/sdk#6211
Expected behavior
dotnet restore
restores dependencies including the local project testlib
Actual behavior
dotnet restore
is unable to resolve the local dependecty testlib
Example output
C:\Users\Sanders\testapp
#! dotnet restore
log : Restoring packages for C:\Users\Sanders\testapp\project.json...
info : CACHE https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json
info : CACHE https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethost/index.json
error: Unable to resolve 'testlib (>= 1.0.0)' for '.NETCoreApp,Version=v1.0'.
info : Committing restore...
log : Lock file has not changed. Skipping lock file write. Path: C:\Users\Sanders\testapp\project.lock.json
log : C:\Users\Sanders\testapp\project.json
log : Restore failed in 656ms.
Errors in C:\Users\Sanders\testapp\project.json
Unable to resolve 'testlib (>= 1.0.0)' for '.NETCoreApp,Version=v1.0'.
NuGet Config files used:
C:\Users\Sanders\AppData\Roaming\NuGet\NuGet.Config
C:\ProgramData\nuget\Config\Microsoft.VisualStudio.Offline.config
Feeds used:
https://api.nuget.org/v3/index.json
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Environment data
dotnet --info
output:
.NET Command Line Tools (1.0.0-preview1-002702)
Product Information:
Version: 1.0.0-preview1-002702
Commit Sha: 6cde21225e
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14342
OS Platform: Windows
RID: win10-x64
Workaround steps
- Inside testlib rename src folder to testlib
- Inside global.json change “src” to “testlib” (this step doesn’t seem to matter as dotnet restore seems to ignore global.json)
- Inside testapp create folder
src
- Move project.json and Program.cs inside src
- Run
dotnet restore
dotnet restore
can now find and restore testlib
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
dotnet restore fails to resolve local dependencies with a ...
Workaround steps. Inside testlib rename src folder to testlib; Inside global.json change "src" to "testlib" (this step doesn't seem ...
Read more >Dotnet restore from local folder Net Core
Package Restore feature will install all referenced packages before a project is built, thereby ensuring that all dependencies are available to ...
Read more >dotnet restore command - .NET CLI
Learn how to restore dependencies and project-specific tools with the dotnet restore command.
Read more >Troubleshooting NuGet Package Restore in Visual Studio
This article focuses on common errors when restoring packages and steps to resolve them. Package Restore tries to install all package ...
Read more >NuGet Package Restore
NuGet Package Restore restores all of a project's dependencies that are listed in either a project file or a packages.config file. You can ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is expected, global.json needs to be in a parent folder.
@golf1052 for project-to-project references to work the projects must be in the domain of a single global.json. It is the global.json that describes where peer projects can be found. Please restructure your projects like this: