Skip to content

Latest commit

 

History

History
130 lines (83 loc) · 5.66 KB

upstream-sources.md

File metadata and controls

130 lines (83 loc) · 5.66 KB
title description ms.assetid ms.service ms.topic ms.date monikerRange recommendations
Use packages from nuget.org
How to consume packages from nuget.org with Azure Artifacts upstream sources
301f954f-a35a-4fe2-b7fd-c78e534d9b16
azure-devops-artifacts
conceptual
11/27/2023
<= azure-devops
true

Use packages from NuGet Gallery

[!INCLUDE version-lt-eq-azure-devops]

With Azure Artifacts upstream sources, developers are able to consume packages from public registries such as nuget.org and npmjs.com. This article will walk you through the process of setting up your project and using the command line to effectively consume NuGet packages from the NuGet Gallery. In this article, you'll learn how to:

[!div class="checklist"]

  • Enable upstream sources for your feed
  • Add NuGet Gallery as an upstream source
  • Connect to your feed
  • Install packages from nuget.org

Prerequisites

Enable upstream sources on your feed

If you don't have a feed, follow these steps to create a new one and make sure to check the upstream sources checkbox to enable them. If you already have a feed, you can jump to the next step to add the NuGet Gallery as an upstream source.

[!INCLUDE ]

Add NuGet Gallery upstream source

If you've checked the upstream sources checkbox when making your feed, NuGet Gallery should have been added automatically. If not, add it manually by following these steps:

  1. Sign in to your Azure DevOps organization, and then navigate to your project.

  2. Select Artifacts, and then select your feed.

  3. Select the gear icon button gear icon to navigate to your Feed settings.

  4. Select Upstream Sources, and then select Add Upstream to add a new upstream source.

  5. Select Public source, and then select NuGet Gallery from the dropdown menu.

  6. Select Save when you're done, and then select Save one more time at the top right corner to save your changes.

Note

The service index location for nuget.org is https://api.nuget.org/v3/index.json.

Connect to feed

  1. Sign in to your Azure DevOps organization, and then navigate to your project.

  2. Select Artifacts, and then select your feed.

  3. Select Connect to feed, and then select NuGet.exe.

  4. Add a nuget.config file in the same folder as your .csproj or .sln file. Paste the provided XML snippet into your file. If you use the examples below, make sure you replace the placeholders with the appropriate values for your scenario.

    • Organization-scoped feed:

      <?xml version="1.0" encoding="utf-8"?>
      <configuration>
        <packageSources>
          <clear />
          <add key="<SOURCE_NAME>" value="https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json" />
        </packageSources>
      </configuration>
    • Project-scoped feed:

      <?xml version="1.0" encoding="utf-8"?>
      <configuration>
        <packageSources>
          <clear />
          <add key="<SOURCE_NAME>" value="https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json" />
        </packageSources>
      </configuration>

Install packages from NuGet Gallery

With our project now configured to authenticate with our feed, we can now proceed to install packages from the NuGet Gallery upstream. In this example, we will install the Serilog diagnostic logging library:

  1. Navigate to the NuGet Gallery at https://www.nuget.org/.

  2. Search for the Serilog package, and then select it to navigate to the details page.

  3. Select the Package Manager tab, and copy the command. In our example, the command is as follows:

    NuGet\Install-Package Serilog -Version 3.1.2-dev-02097
  4. Open your project in Visual Studio, and then select Tools > NuGet Package Manager > Package Manager Console to open the console window.

  5. Paste your command in the Package Manager Console window, and press Enter to install your package.

Note

You must be a Collaborator, a Contributor, or an Owner to save packages from upstream. See Permissions for more details.

View saved packages

  1. Sign in to your Azure DevOps organization, and then navigate to your project.

  2. Select Artifacts, and then select your feed from the dropdown menu.

  3. Select the NuGet Gallery source from the dropdown menu to filter for packages from this upstream.

  4. The Serilog package, installed in the previous step, is now available in our feed. Azure Artifacts automatically saved a copy to our feed when we executed the install command.

    :::image type="content" source="media/package-saved-from-upstream.png" alt-text="A screenshot showing the package that was saved from upstream.":::

Related articles