我们在内部部署的TFS 2017 Feed中有几个内部nuget包。它们仅供我们的内部应用程序使用;但是,当我们安装外部nuget.org托管软件包时,Visual Studio正试图从内部源和nuget.org检索它们,并且需要花费大量时间来安装软件包。有没有办法告诉它从特定服务器下载?
以下是我尝试在软件包管理器控制台中安装Microsoft.Owin.Security.OpenIdConnect的部分列表:
PM> Install-Package Microsoft.Owin.Host.SystemWeb -verbose
GET https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin.host.systemweb/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.host.systemweb/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.host.systemweb/index.json
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.host.systemweb/index.json 61ms
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.host.systemweb/index.json 60ms
OK https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin.host.systemweb/index.json 143ms
CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin.host.systemweb/index.json
Attempting to gather dependency information for package 'Microsoft.Owin.Host.SystemWeb.4.0.0' with respect to project 'WebAppName.Web', targeting '.NETFramework,Version=v4.5.1'
Package Microsoft.Owin.Host.SystemWeb from source NuGet official package source gathered from cache.
Package Microsoft.Owin.Host.SystemWeb from source nuget.org gathered from cache.
Package Microsoft.Owin.Host.SystemWeb from source Local Source gathered from cache.
Package Microsoft.Owin.Host.SystemWeb from source OurCustomFeed gathered from cache.
Package Microsoft.Owin.Host.SystemWeb from source Microsoft Visual Studio Offline Packages gathered from cache.
Package Microsoft.Owin.Host.SystemWeb from source OurCustomFeed Repo gathered from cache.
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/owin/index.json
CACHE https://api.nuget.org/v3/registration3-gz-semver2/owin/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/owin/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.security/index.json
CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin.security/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.security/index.json
CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin.security.cookies/index.json
CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin.security/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.security.cookies/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.security.cookies/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin/index.json
CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin.security.cookies/index.json
CACHE https://api.nuget.org/v3/registration3-gz-semver2/owin/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.security.openidconnect/index.json
CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin/index.json
CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin.security.openidconnect/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.security.openidconnect/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/system.identitymodel.tokens.jwt/index.json
GET https://api.nuget.org/v3/registration3-gz-semver2/system.identitymodel.tokens.jwt/index.json
CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/system.identitymodel.tokens.jwt/index.json
CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin.security.openidconnect/index.json
GET https://api.nuget.org/v3/registration3-gz-semver2/microsoft.identitymodel.logging/index.json
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.security/index.json 62ms
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/owin/index.json 64ms
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/owin/index.json 76ms
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.logging/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.logging/index.json
CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.identitymodel.protocols/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.protocols/index.json
OK https://api.nuget.org/v3/registration3-gz-semver2/system.identitymodel.tokens.jwt/index.json 41ms
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin/index.json 72ms
CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.identitymodel.protocols/index.json
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.security/index.json 93ms
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.protocols/index.json
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.security.cookies/index.json 86ms
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.security.cookies/index.json 93ms
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.security.openidconnect/index.json 90ms
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin/index.json 99ms
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.owin.security.openidconnect/index.json 80ms
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/system.identitymodel.tokens.jwt/index.json 76ms
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/system.identitymodel.tokens.jwt/index.json 67ms
CACHE https://api.nuget.org/v3/registration3-gz-semver2/system.identitymodel.tokens.jwt/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.protocols.openidconnect/index.json
CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.identitymodel.protocols.openidconnect/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.tokens/index.json
GET https://api.nuget.org/v3/registration3-gz-semver2/microsoft.identitymodel.tokens/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.protocols.openidconnect/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.tokens/index.json
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.logging/index.json 67ms
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.protocols/index.json 59ms
GET https://api.nuget.org/v3/registration3-gz-semver2/newtonsoft.json/index.json
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.logging/index.json 69ms
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/newtonsoft.json/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/newtonsoft.json/index.json
CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.identitymodel.protocols.openidconnect/index.json
GET https://api.nuget.org/v3/registration3-gz-semver2/microsoft.identitymodel.protocol.extensions/index.json
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.protocol.extensions/index.json
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.protocols/index.json 64ms
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.protocol.extensions/index.json
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.protocols.openidconnect/index.json 51ms
GET https://api.nuget.org/v3/registration3-gz-semver2/product.utilities/index.json
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.tokens/index.json 64ms
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.protocols.openidconnect/index.json 56ms
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/microsoft.identitymodel.tokens/index.json 54ms
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/product.utilities/index.json
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/newtonsoft.json/index.json 52ms
NotFound http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/newtonsoft.json/index.json 51ms
GET http://tfs.company.com/tfs/TfsRep/_packaging/18c3561d-f194-4914-90e2-9506ea56646c/nuget/v3/registrations2/product.utilities/index.json
GET https://api.nuget.org/v3/registration3-gz-semver2/microsoft.aspnet.webapi.client/index.json
GET https://api.nuget.org/v3/registration3-gz-semver2/microsoft.owin.security/index.json
... Hundreds of more similiar calls ....
请注意每个文件如何调用我们公司的TFS 2017服务器(tfs.company.com),然后调用Nuget服务器(api.nuget.org)。
我尝试的事情:
其他可能性
答案 0 :(得分:1)
Visual Studio正在尝试从内部源和nuget.org检索它们,并且需要花费大量时间来安装软件包。有没有办法告诉它从特定服务器下载?
这是NuGet的默认行为。当我们将NuGet包安装到项目中时,NuGet 3.0+将向所有NuGet源发送多任务请求,以便我们可以更有效地获得反馈。
这就是输出日志中以下请求的原因:
Package Microsoft.Owin.Host.SystemWeb from source NuGet official package source gathered from cache.
Package Microsoft.Owin.Host.SystemWeb from source nuget.org gathered from cache.
Package Microsoft.Owin.Host.SystemWeb from source Local Source gathered from cache.
Package Microsoft.Owin.Host.SystemWeb from source OurCustomFeed gathered from cache.
Package Microsoft.Owin.Host.SystemWeb from source Microsoft Visual Studio Offline Packages gathered from cache.
Package Microsoft.Owin.Host.SystemWeb from source OurCustomFeed Repo gathered from cache.
如果您想从特定服务器下载,可以通过Parameters -Source特定来源安装此软件包:
Install-Package Microsoft.Owin.Host.SystemWeb -verbose -source nuget.org
在这种情况下,我们只能从源nuget.org
检索包Microsoft.Owin.Host.SystemWeb,而不是检测所有nuget包源。
但是,如果安装的nuget包具有依赖关系,NuGet将在尝试收集依赖关系信息时检测所有包源。这也是NuGet的默认行为。我们在安装nuget包时不需要将所有依赖包添加到自定义Feed中。
当前解决方法是您在安装某些指定包时取消TFS 2017 Feed(取消选中TFS 2017包源)。
为了跟踪潜在的NuGet问题,我在Github上打开一个帖子,你可以查看这个帖子以获得最新的反馈。
希望这有帮助。