NuGet.org 上游源

Azure DevOps Services | Azure DevOps Server 2020 | Azure DevOps Server 2019 | TFS 2018

在源上启用上游源后,开发人员可以使用公共注册表中的包,例如 nuget.org 和 npmjs.com。 本文介绍如何添加NuGet库上游源,以使用来自 nuget.org 公共注册表的NuGet包。

  1. 选择Artifacts,然后选择源。

  2. 选择齿轮图标 gear icon 按钮以导航到 “源”设置

  3. 选择 上游源

    A screenshot showing how to access upstream sources from feed settings.

  4. 选择“ 添加上游”。

    A screenshot showing how to add an upstream source.

  5. 选择 “公共源”。

    Screenshot showing how to add a new upstream source.

  6. 从下拉菜单中选择NuGet库。 完成后,选择“ 保存 ”。

    Screenshot showing how to add the nuget.org upstream source.

    注意

    nuget.org 的服务索引位置为 https://api.nuget.org/v3/index.json

  7. 选择右上角的 “保存” 以保存所做的更改。

更新nuget.config

  1. 选择Artifacts,然后选择源。

  2. 选择要馈送的连接,然后选择NuGet.exe

    A screenshot showing how to connect to NuGet feeds.

  3. 复制Project安装程序部分中的 XML 代码片段。

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <packageSources>
        <clear />
        <add key="<FEED_NAME>" value="https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json" />
      </packageSources>
    </configuration>
    
  4. 在项目的根目录中创建新的 nuget.config 文件。

  5. 将 XML 代码片段粘贴到nuget.config文件中。

查看已保存的包

可以通过从下拉菜单中选择来查看从NuGet库中保存的包。

A screenshot showing how to filter packages by source.

A screenshot showing how to filter packages by source in TFS