首页 > 解决方案 > 无法访问 NuGet 源

问题描述

我正在尝试从私人来源添加 NuGet 包;https://[provider].pkgs.visualstudio.com/[package]/nuget/v3/index.json(故意省略了提供者和包)。

我已将源代码添加到项目中的本地 Nuget.Config 文件中

<configuration>
    <packageSources>
        <add key="[name]" value="https://[provider].pkgs.visualstudio.com/_packaging/[package]/nuget/v3/index.json" />
    </packageSources>
    <packageSourceCredentials>
        <[name]>
            <add key="Username" value="[username]" />
            <add key="Password" value="[password]" />
        </[name]>
    </packageSourceCredentials>
</configuration>

当我通过 CLI 请求源列表时,我得到以下信息

Registered Sources:

  1.  [name] [Enabled]
   https://[provider].pkgs.visualstudio.com/_packaging/[package]/nuget/v3/index.json
  2.  nuget.org [Enabled]
      https://api.nuget.org/v3/index.json

但是,当我尝试将特定包添加到我的项目时,我收到以下错误

error: Unable to load the service index for source https://[provider].pkgs.visualstudio.com/_packaging/[package]/nuget/v3/index.json.
error: Response status code does not indicate success: 401 (Unauthorized).

自然的解释当然是我输入了无效的凭据。但是,当我在浏览器中访问源时,我可以使用相同的凭据登录并检查 index.json 文件。

我想知道在添加私有 NuGet 源的过程中是否会遗漏一些东西?

(NuGet 版本:4.9.3.5777)

标签: nuget

解决方案


我刚刚发现我错过了什么。我需要安装 Azure Artifacts Credential Provider 并按照GitHub 页面上的说明进行操作。


推荐阅读