Skip to content

Commit 81a5445

Browse files
authored
Merge pull request #8295 from MicrosoftDocs/artifacts/482880
Consume packages from NuGet upstream
2 parents a6bc812 + 6e99de9 commit 81a5445

File tree

3 files changed

+52
-78
lines changed

3 files changed

+52
-78
lines changed
34 KB
Loading
102 KB
Loading
Lines changed: 52 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,64 @@
11
---
2-
title: Consume packages from nuget.org
3-
description: How to consume packages from nuget.org with Azure Artifacts upstream sources
2+
title: Consume packages from the NuGet Gallery
3+
description: Learn how to consume packages from nuget.org with Azure Artifacts upstream sources.
44
ms.assetid: 301f954f-a35a-4fe2-b7fd-c78e534d9b16
55
ms.service: azure-devops-artifacts
66
ms.topic: how-to
7-
ms.date: 04/16/2024
7+
ms.date: 09/5/2025
88
monikerRange: '>= azure-devops-2020'
99
"recommendations": "true"
1010
---
1111

12-
# Use packages from NuGet Gallery
12+
# Use packages from the NuGet Gallery
1313

1414
[!INCLUDE [version-gt-eq-2020](../../includes/version-gt-eq-2020.md)]
1515

16-
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:
17-
18-
> [!div class="checklist"]
19-
> * Enable upstream sources for your feed
20-
> * Add NuGet Gallery as an upstream source
21-
> * Connect to your feed
22-
> * Install packages from nuget.org
16+
Azure Artifacts upstream sources make it easy for developers to pull packages from public registries like *nuget.org* and *npmjs.com*. In this article, you learn how to set up your project and use the command line to consume NuGet packages from the NuGet Gallery.
2317

2418
## Prerequisites
2519

26-
- An Azure DevOps organization and a project. Create an [organization](../../organizations/accounts/create-organization.md) or a [project](../../organizations/projects/create-project.md#create-a-project) if you haven't already.
27-
28-
- An Azure Artifacts feed.
29-
30-
- Download [NuGet](https://www.nuget.org/downloads).
20+
| **Product** | **Requirements** |
21+
|--------------------|----------------------------------------|
22+
| **Azure DevOps** | - An Azure DevOps [organization](../../organizations/accounts/create-organization.md).<br>- An Azure DevOps [project](../../organizations/projects/create-project.md).<br> - An Azure Artifacts [feed](../get-started-nuget.md#create-a-feed).<br> - Download and install the [Azure Artifacts Credential Provider](https://github.com/microsoft/artifacts-credprovider).<br> - Install the latest [NuGet version](https://www.nuget.org/downloads). |
3123

32-
- Download and install [Azure Artifacts Credential Provider](https://github.com/microsoft/artifacts-credprovider#azure-artifacts-credential-provider).
24+
## Create a feed and enable upstream sources
3325

34-
## Enable upstream sources on your feed
26+
If you haven't created a feed yet, follow the steps below to create a new feed and enable upstream sources. If you already have a feed, proceed to the [next step](#add-nuget-gallery-upstream-source) to add the NuGet Gallery as an upstream source.
3527

36-
If you haven't created a feed yet, follow the steps below to create a new one and make sure you select the upstream sources checkbox to enable them. If you already have a feed, proceed to the [next step](#add-nuget-gallery-upstream-source) to add the NuGet Gallery as an upstream source.
37-
38-
[!INCLUDE [](../includes/create-feed.md)]
39-
40-
## Add NuGet Gallery upstream source
41-
42-
::: moniker range="azure-devops"
43-
44-
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:
45-
46-
1. Sign in to your Azure DevOps organization, and then navigate to your project.
28+
1. Sign in to your Azure DevOps organization and navigate to your project.
4729

48-
1. Select **Artifacts**, and then select your feed.
30+
1. Select **Artifacts**, and then select **Create Feed**.
4931

50-
1. Select the gear icon button ![gear icon](../../media/icons/gear-icon.png) to navigate to your **Feed settings**.
32+
1. Provide a **Name** for your feed, select the **Visibility** option to define who can view your packages, and choose your **Scope**. Azure Artifacts recommends scoping feeds to a project rather than the entire organization.
5133

52-
1. Select **Upstream Sources**, and then select **Add Upstream** to add a new upstream source.
34+
1. Make sure to check the **Include packages from common public sources** option, as you'll need this to consume packages from public registries such as *nuget.org*, *npmjs.com* etc.
5335

54-
1. Select **Public source**, and then select **NuGet Gallery** from the dropdown menu.
36+
1. Select **Create** when you're done.
5537

56-
1. Select **Add** when you're done, and then select **Save** one more time at the top right corner to save your changes.
38+
:::image type="content" source="../media/enable-upstream-nuget-gallery.png" alt-text="A screenshot displaying how to create a new feed and enable upstream sources in Azure Artifacts.":::
5739

58-
::: moniker-end
40+
## Add NuGet Gallery upstream source
5941

60-
::: moniker range="azure-devops-2022"
42+
If you checked the Upstream sources checkbox when creating your feed (as shown in the previous section), the NuGet Gallery should have been added automatically to your feed’s upstream sources. If you're working with a different feed or forgot to check that option, you can manually add the NuGet Gallery by following these steps:
6143

62-
1. Sign in to your Azure DevOps server, and then navigate to your project.
44+
1. Sign in to Azure DevOps, and then navigate to your project.
6345

64-
1. Select **Artifacts**, and then select your feed.
46+
1. Select **Artifacts**, and then select your feed from the dropdown menu.
6547

6648
1. Select the gear icon button ![gear icon](../../media/icons/gear-icon.png) to navigate to your **Feed settings**.
6749

50+
::: moniker range="azure-devops || azure-devops-2022"
51+
6852
1. Select **Upstream Sources**, and then select **Add Upstream**.
6953

70-
1. Select **Public source**, and then select **NuGet Gallery** from the dropdown menu.
54+
1. Select **Public source**, select **NuGet Gallery** from the dropdown menu, and then select **Add**.
7155

72-
1. Select **Save** when you're done, and then select **Save** one more time at the top right corner to save your changes.
56+
1. Select **Save** at the top right corner, then select **Save** again to confirm and apply your changes.
7357

7458
::: moniker-end
7559

7660
::: moniker range="=azure-devops-2020"
7761

78-
1. Sign in to your Azure DevOps server, and then navigate to your project.
79-
80-
1. Select **Artifacts**, and then select your feed.
81-
82-
1. Select the gear icon button ![gear icon](../../media/icons/gear-icon.png) to navigate to your **Feed settings**.
83-
8462
1. Select **Upstream Sources**, and then select **Add upstream source**.
8563

8664
1. Select **Public source**, and then select **NuGet Gallery** from the dropdown menu.
@@ -89,38 +67,42 @@ If you've checked the upstream sources checkbox when making your feed, NuGet Gal
8967

9068
::: moniker-end
9169

92-
## Connect to feed
70+
## Connect to your feed
71+
72+
In this section, you learn how to set up your project to authenticate with your Azure Artifacts feed and save packages from upstream sources such as the NuGet Gallery.
9373

9474
::: moniker range="azure-devops"
9575

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

98-
1. Select **Artifacts**, and then select your feed.
78+
1. Select **Artifacts**, and then select your feed from the dropdown menu.
9979

10080
1. Select **Connect to feed**, and then select **NuGet.exe**.
10181

102-
1. 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.
82+
1. Make sure you've installed the prerequisites, then add a *nuget.config* file in the same folder as your *.csproj* or *.sln* file.
10383

104-
- **Organization-scoped feed**:
84+
1. Paste the XML snippet provided in the **Project setup** section into your file. Your file should resemble the following:
85+
86+
- **Project-scoped feed**:
10587

10688
```xml
10789
<?xml version="1.0" encoding="utf-8"?>
10890
<configuration>
10991
<packageSources>
11092
<clear />
111-
<add key="<SOURCE_NAME>" value="https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json" />
93+
<add key="<SOURCE_NAME>" value="https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json" />
11294
</packageSources>
11395
</configuration>
11496
```
115-
116-
- **Project-scoped feed**:
97+
98+
- **Organization-scoped feed**:
11799

118100
```xml
119101
<?xml version="1.0" encoding="utf-8"?>
120102
<configuration>
121103
<packageSources>
122104
<clear />
123-
<add key="<SOURCE_NAME>" value="https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json" />
105+
<add key="<SOURCE_NAME>" value="https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json" />
124106
</packageSources>
125107
</configuration>
126108
```
@@ -129,9 +111,9 @@ If you've checked the upstream sources checkbox when making your feed, NuGet Gal
129111

130112
::: moniker range="azure-devops-2020 || azure-devops-2022"
131113

132-
1. Sign in to your Azure DevOps server, and then navigate to your project.
114+
1. Sign in to your Azure DevOps collection, and then navigate to your project.
133115

134-
1. Select **Artifacts**, and then select your feed.
116+
1. Select **Artifacts**, and then select your feed from the dropdown menu.
135117

136118
1. Select **Connect to Feed**, and then select **NuGet.exe** from the left navigation pane.
137119

@@ -141,48 +123,40 @@ If you've checked the upstream sources checkbox when making your feed, NuGet Gal
141123

142124
## Install packages from NuGet Gallery
143125

144-
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:
126+
Now that your project is configured to authenticate with your Azure Artifacts feed, you can proceed to install packages from the NuGet Gallery upstream. In this example, you'll install the *MCP C# SDK* for the Model Context Protocol for .NET applications to interact with MCP clients and servers:
145127

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

148-
1. Search for the *Serilog* package, and then select it to navigate to the details page.
130+
1. Search for the *ModelContextProtocol*, then select it to open the details page.
149131

150-
1. Select the **Package Manager** tab, and copy the command. In our example, the command is as follows:
132+
1. Select the **.NET CLI** tab, and copy the command. In this example, the command is:
151133

152134
```Command
153-
NuGet\Install-Package Serilog -Version 3.1.2-dev-02097
135+
dotnet add package ModelContextProtocol --version 0.3.0-preview.4
154136
```
155137

156-
1. Open your project in Visual Studio, and then select **Tools** > **NuGet Package Manager** > **Package Manager Console** to open the console window.
138+
1. Open a command prompt window, navigate to your project directory, then paste your command and press *Enter* to install the package.
157139

158-
1. Paste your command in the Package Manager Console window, and press Enter to install your package.
140+
Once installed, a copy of the package will be automatically saved to your feed, ensuring availability if NuGet Gallery is down and protecting your workflow from other corrupted or malicious packages from the public registry.
159141

160142
[!INCLUDE [save-requires-collaborator](../includes/save-requires-collaborator.md)]
161143

162144
## View saved packages
163145

164-
::: moniker range="azure-devops"
165-
166-
1. Sign in to your Azure DevOps organization, and then navigate to your project.
146+
1. Sign in to Azure DevOps, and navigate to your project.
167147

168-
::: moniker-end
169-
170-
::: moniker range="< azure-devops"
148+
1. Select **Artifacts**, then select your feed from the dropdown menu.
171149

172-
1. Sign in to your Azure DevOps server, and then navigate to your project.
150+
1. Select the **NuGet Gallery** source from the dropdown menu to filter for packages from this upstream.
173151

174-
::: moniker-end
152+
1. The *ModelContextProtocol* packages, installed in the previous step, is now available in our feed. Azure Artifacts automatically saved a copy to your feed.
175153

176-
2. Select **Artifacts**, and then select your feed from the dropdown menu.
154+
:::image type="content" source="../media/package-saved-from-nuget-upstream.png" alt-text="A screenshot displaying the MCP package saved to the feed." lightbox="../media/package-saved-from-nuget-upstream.png":::
177155

178-
3. Select the **NuGet Gallery** source from the dropdown menu to filter for packages from this upstream.
156+
## Related content
179157

180-
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.
181-
182-
:::image type="content" source="media/package-saved-from-upstream.png" alt-text="A screenshot showing the package that was saved from upstream.":::
183-
184-
## Related articles
158+
- [Publish packages to NuGet.org](./publish-to-nuget-org.md)
185159

186160
- [Publish NuGet packages with Azure Pipelines](../../pipelines/artifacts/nuget.md)
187-
- [Publish packages to NuGet.org](./publish-to-nuget-org.md)
161+
188162
- [Manage permissions](../feeds/feed-permissions.md)

0 commit comments

Comments
 (0)