NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 252 forks source link

NuGet gather dependency information from a specify nuget package source. #6899

Open liushuanggang opened 6 years ago

liushuanggang commented 6 years ago

Details about Problem

When we install a nuget package Microsoft.Owin.Host.SystemWeb with a specify nuget source -source nuget.org, which dependencies are Owin and Microsoft.Owin. NuGet will retrieve nuget package Microsoft.Owin.Host.SystemWeb only from the specify source nuget.org but it detect the dependencies packages from other package sources.

For example, I install the nuget with command line on the Package Manager Console:

Install-Package Microsoft.Owin.Host.SystemWeb -verbose -source nuget.org

The output log:

PM> Install-Package Microsoft.Owin.Host.SystemWeb -verbose -source nuget.org GET https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin.host.systemweb/index.json OK https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin.host.systemweb/index.json 544ms

Attempting to gather dependency information for package 'Microsoft.Owin.Host.SystemWeb.4.0.0' with respect to project 'ConsoleApp4', targeting '.NETFramework,Version=v4.6.1' Package Microsoft.Owin.Host.SystemWeb from source nuget.org gathered from cache. GET https://dotnet.myget.org/F/dotnet-core/api/v3/registration1/owin/index.json CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin/index.json GET https://dotnet.myget.org/F/dotnet-core/api/v3/registration1/microsoft.owin/index.json CACHE https://api.nuget.org/v3/registration3-gz-semver2/owin/index.json NotFound https://dotnet.myget.org/F/dotnet-core/api/v3/registration1/owin/index.json 646ms NotFound https://dotnet.myget.org/F/dotnet-core/api/v3/registration1/microsoft.owin/index.json 1508ms

As you can see from the log, nuget detect the dependencies packages from other package source myget. Sometimes detection time will be very long, so I want if we could have any option to force nuget only detect the specify nuget source when it attempting to gather dependency information, for example, Install-Package Microsoft.Owin.Host.SystemWeb -verbose -source nuget.org -IncludeDependecies

NuGet version (x.x.x.xxx):

nuget 4.6.0

VS version:

VS2017 15.6.6

OS version:

Win10

jainaashish commented 6 years ago

This is by design to resolve dependencies from all active sources. One workaround is to disable all other sources from tools -> options -> NuGet package Manager

liushuanggang commented 6 years ago

@jainaashish, Thanks for your reply. Yes, I know it is by design. Your workaround is exactly what I am did. But if there is a a parameter here that allows us to choose whether restore dependencies from nuget.org? like, -source nuget.org -IncludeDependecies. Is this better? Or this request will have a lower priority.

madcodemonkey commented 6 years ago

@jainaashish What's driving our team nuts is that we have a TFS 2017 feed with an internal package that has dependencies on Nuget.org. It takes a long time for a solution to upgrade to a newer version of our internal package because it is trying to retrieve all the dependencies from our internal server, which it doesn't have them (there on Nuget.org). I tried downloading the packages from Nuget.org and putting them on our internal feed, but it doesn't make any differences in the speed because there are still lots of requests that fail because there are dependencies OTHER than the ones that the package says it depends upon (most are for things that come with windows, but I guess it has to check to see if a Nuget package should be download if a particular package isn't on a computer). It would be nice to be able to give a package a hint as to where to get a dependency. So perhaps in the nuspec file, you could name your dependencies and then set a hint to its location (e.g.,Nuget.org or from an internal feed ).