Azure DevOps Services | Azure DevOps Server 2020 | Azure DevOps Server 2019 | TFS 2018
Using upstream sources in your feed enables you to manage your application dependencies from a single feed. Using upstream sources makes it easy to consume packages from public registries while having protection against outages or compromised packages. You can also publish your own packages to the same feed and manage all your dependencies in one location.
This tutorial will walk you through how to enable upstream sources on your feed and consume packages from public registries such as NuGet.org or npmjs.com.
In this tutorial, you will:
Create a new feed and enable upstream sources.
Set up your configuration file.
Run an initial package restore to populate your feed.
Check your feed to view the saved copy of the packages you consumed from the public registry.
Create a feed and enable upstream sources
Select Artifacts.
Select Build & Release, and then select Packages.
Select Create Feed to create a new feed.
Select New Feed to create a new feed.
Provide a name for your feed, and then select its visibility. Make sure your check the Include packages from common public sources checkbox to enable upstream sources. Select Create when you are done
Provide a name for your feed, and then select its visibility. Make sure your check the Include packages from common public sources checkbox to enable upstream sources. Select Create when you are done
Set up the configuration file
Now that we created our feed, we need to update the config file to point to our feed. To do this we must:
Select Artifacts, and then select Connect to feed.
On the left side of the page, select the npm tab.
Follow the instructions in the Project setup section to set up your config file.
Select Build & Release > Packages, and then select Connect to Feed.
Copy the highlighted snippet to add it to your config file.
If you don't have a .npmrc file already, create a new one in the root of your project (in the same folder as your package.json). Open your new .npmrc file and paste the snippet you just copied in the previous step.
Select Artifacts, and then select your feed.
Select Connect to feed, and then choose NuGet.exe.
Copy the XML snippet in the Project Setup section.
Create a new file named nuget.config in the root of your project.
Paste the XML snippet in your config file.
Select Artifacts, and then select your feed from the dropdown list.
Select Connect to feed, and then select pip under the Python section.
Create a personal access token with Packaging > Read & write scopes and paste your personal access token into the <password> tag in your settings.xml file.
Select Artifacts, and then select your feed from the dropdown list.
Select Connect to feed, and then select Gradle.
Add the following snippet to the repositories and publishing sections in your build.gradle file:
Create a personal access token with Packaging > Read & write scopes. Paste your personal access token into the <password> tag in your settings.xml file.
Restore packages
Now that you enabled upstream sources and set up your configuration file, we can run the package restore command to query the upstream source and retrieve the upstream packages.
We recommend clearing your local cache first before running the nuget restore. Azure Artifacts will have a saved copy of any packages you installed from upstream.