代码之家  ›  专栏  ›  技术社区  ›  David Yates

有没有办法告诉Visual Studio 2017停止尝试从两个Nuget检索包。组织和TFS 2017 feed?

  •  0
  • David Yates  · 技术社区  · 6 年前

    我们在内部TFS 2017 feed中有几个内部nuget包。它们仅由我们的内部应用程序使用;然而,当我们安装外部nuget时。org托管的包,Visual Studio正在尝试从内部源和nuget中检索它们。org,安装软件包需要花费大量时间。有没有办法告诉它从特定服务器下载?

    下面是我尝试安装Microsoft的部分列表。奥温。安全package manager控制台中的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有关。我们在解决方案级别拥有的配置文件,但我已经删除了它,这种情况仍然存在。
    • 我已经看过了 nuget.config settings
    • 我尝试从UI工具安装,只选择Nuget。组织机构
    • 我在Google和Stack Overflow中搜索了可能存在的TFS提要问题,但似乎找不到有此问题的人。

    其他可能性

    • 我不确定将我们的TFS服务器升级到TFS 2018并使用上游源(TFS 2017没有nuget.org作为源)是否会解决此问题,因为这似乎与Visual Studio获取和检查nuget源的方式有关。我们计划在今年第三季度之前完成这项工作,因此我想找到一个解决方案,而不是将我们的feed移出2017年TFS。
    1 回复  |  直到 6 年前
        1
  •  1
  •   Leo Liu    6 年前

    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
    

    在这种情况下,我们可以检索Microsoft包。奥温。主办仅来自源的SystemWeb nuget.org 而不是检测所有nuget包源。

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

    这个 当前解决方法 是指在安装某些指定软件包时,您可以不使用TFS 2017源(取消选中TFS 2017软件包源)。

    为了跟踪潜在的NuGet问题,我在 Github ,您可以检查此线程以获取最新反馈。

    希望这有帮助。