有没有办法告诉Visual Studio 2017停止尝试从Nuget.org和TFS 2017源检索包?

有没有办法告诉Visual Studio 2017停止尝试从Nuget.org和TFS 2017源检索包?,tfs,visual-studio-2017,nuget,Tfs,Visual Studio 2017,Nuget,我们在内部部署的TFS 2017提要中有两个内部nuget包。它们仅用于我们的内部应用程序;然而,当我们安装外部nuget.org托管的包时,Visual Studio试图从内部源和nuget.org检索它们,安装包需要花费大量时间。有没有办法告诉它从特定的服务器下载 以下是我试图在package manager控制台中安装Microsoft.Owin.Security.OpenIdConnect的部分列表: PM> Install-Package Microsoft.Owin.Host.

我们在内部部署的TFS 2017提要中有两个内部nuget包。它们仅用于我们的内部应用程序;然而,当我们安装外部nuget.org托管的包时,Visual Studio试图从内部源和nuget.org检索它们,安装包需要花费大量时间。有没有办法告诉它从特定的服务器下载

以下是我试图在package manager控制台中安装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

我尝试过的事情:

我认为这可能与我们在解决方案级别拥有的nuget.config文件有关,但我已经删除了它,这种情况仍然存在。 我已经看过这本书了。 我尝试过从UI工具安装,只选择了Nuget.org 我在Google和Stack Overflow上搜索过可能存在的TFS提要问题,但似乎找不到有此问题的人。 其他可能性

我不确定将我们的TFS服务器升级到TFS 2018并使用上游源TFS 2017是否没有nuget.org作为源来解决此问题,因为这似乎与Visual Studio获取和检查nuget源的方式有关。我们在今年第三季度之前不打算这样做,因此我想找到一个解决方案,而不是将我们的feed移出2017年TFS。 VisualStudio正在尝试从内部源代码和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.
如果要从特定服务器下载,可以通过以下方式指定安装此软件包的源:

在这种情况下,我们只能从源nuget.org检索包Microsoft.Owin.Host.SystemWeb,而不是检测所有nuget包源

但是,如果安装的nuget包具有依赖项,nuget将在尝试收集依赖项信息时检测所有包源。这也是NuGet默认行为。在安装nuget包时,我们不需要将所有依赖项包添加到自定义提要

当前的解决方法是,在安装某些指定包时,可以不使用TFS 2017源取消选中TFS 2017包源

为了跟踪潜在的NuGet问题,我在上打开了一个线程,您可以检查这个线程以获得最新的反馈


希望这能有所帮助。

Leo,如果TFS 2017 Nuget包在Nuget.org上有依赖项,那么从内部提要检索该包时,我们也会发现检索速度非常慢。有没有办法告诉TFS 2017,嘿,抓住我们的包,但是所有依赖项都在Nuget.org上,或者这是TFS 2018中的上游源选项应该解决的问题?如果从内部源检索TFS 2017 Nuget包时检索速度慢,如果它从Nuget.org有依赖项,您还可以将依赖项添加到TFS 2017提要并禁用nuget.org源。AFAIK,TFS 2018中的上游源选项仅适用于源npmjs.com而非nuget.org.Leo,它在TFS 2018更新2中:不幸的是,我们要到今年第三季度才会看到该版本,因为我们从2017年TFS更新到2018年。
Install-Package Microsoft.Owin.Host.SystemWeb -verbose -source nuget.org