You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
23
17
24
18
## Prerequisites
25
19
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.
|**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). |
31
23
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
33
25
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.
35
27
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.
47
29
48
-
1. Select **Artifacts**, and then select your feed.
30
+
1. Select **Artifacts**, and then select **Create Feed**.
49
31
50
-
1.Select the gear icon button  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.
51
33
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.
53
35
54
-
1. Select **Public source**, and then select **NuGet Gallery** from the dropdown menu.
36
+
1. Select **Create** when you're done.
55
37
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.":::
57
39
58
-
::: moniker-end
40
+
## Add NuGet Gallery upstream source
59
41
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:
61
43
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.
63
45
64
-
1. Select **Artifacts**, and then select your feed.
46
+
1. Select **Artifacts**, and then select your feed from the dropdown menu.
65
47
66
48
1. Select the gear icon button  to navigate to your **Feed settings**.
1. Select **Upstream Sources**, and then select **Add Upstream**.
69
53
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**.
71
55
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.
73
57
74
58
::: moniker-end
75
59
76
60
::: moniker range="=azure-devops-2020"
77
61
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  to navigate to your **Feed settings**.
83
-
84
62
1. Select **Upstream Sources**, and then select **Add upstream source**.
85
63
86
64
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
89
67
90
68
::: moniker-end
91
69
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.
93
73
94
74
::: moniker range="azure-devops"
95
75
96
76
1. Sign in to your Azure DevOps organization, and then navigate to your project.
97
77
98
-
1. Select **Artifacts**, and then select your feed.
78
+
1. Select **Artifacts**, and then select your feed from the dropdown menu.
99
79
100
80
1. Select **Connect to feed**, and then select **NuGet.exe**.
101
81
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.
103
83
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:
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.
133
115
134
-
1. Select **Artifacts**, and then select your feed.
116
+
1. Select **Artifacts**, and then select your feed from the dropdown menu.
135
117
136
118
1. Select **Connect to Feed**, and then select **NuGet.exe** from the left navigation pane.
137
119
@@ -141,48 +123,40 @@ If you've checked the upstream sources checkbox when making your feed, NuGet Gal
141
123
142
124
## Install packages from NuGet Gallery
143
125
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:
145
127
146
128
1. Navigate to the NuGet Gallery at `https://www.nuget.org/`.
147
129
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.
149
131
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:
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.
157
139
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.
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.
167
147
168
-
::: moniker-end
169
-
170
-
::: moniker range="< azure-devops"
148
+
1. Select **Artifacts**, then select your feed from the dropdown menu.
171
149
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.
173
151
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.
175
153
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":::
177
155
178
-
3. Select the **NuGet Gallery** source from the dropdown menu to filter for packages from this upstream.
156
+
## Related content
179
157
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)
185
159
186
160
- [Publish NuGet packages with Azure Pipelines](../../pipelines/artifacts/nuget.md)
187
-
- [Publish packages to NuGet.org](./publish-to-nuget-org.md)
0 commit comments