Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure DevOps Services | Azure DevOps Server | Azure DevOps Server 2022
This article guides you through setting up your project and restoring NuGet packages using the NuGet command-line interface.
Prerequisites
| Product | Requirements |
|---|---|
| Azure DevOps | - An Azure DevOps organization. - An Azure DevOps project. - An Azure Artifacts feed. - Download and install nuget.exe version 4.8.0.5385 or later. We recommend NuGet 5.5.x or later, which includes important bug fixes for cancellations and timeouts. |
Set up the Azure Artifacts Credential Provider
The Azure Artifacts Credential Provider enables secure authentication to your Azure Artifacts feeds. To use it with nuget.exe, you must first add it to NuGet’s plugin search path. For details, see Plugin Installation and discovery. Once the plugin is added, follow the installation steps for your operating system:
Use one of the following methods to install the Azure Artifacts Credential Provider:
Manual installation
Download the latest Microsoft.NetFx48.NuGet.CredentialProvider.zip release.
Extract the zip file.
Copy the
netfxfolder from the extracted archive to%UserProfile%/.nuget/plugins/. Thenetfxfolder is required for nuget.exe compatibility.
Install using the helper script
Alternatively, you can use the automated helper script for a streamlined installation. Ensure you have PowerShell 5.1 or later, and then run:
iex "& { $(irm https://aka.ms/install-artifacts-credprovider.ps1) } -AddNetfx"
For more information, see the Azure Artifacts Credential Provider repository.
Connect to a feed
Sign in to your Azure DevOps organization, and then navigate to your project.
Select Artifacts, and then select your feed from the dropdown menu.
Select Connect to feed, and then select NuGet.exe from the left navigation pane.
Add a nuget.config file to your project, in the same folder as your csproj or .sln file. Paste the provided XML snippet into your file. The snippet should look like the following:
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>
Sign in to your Azure DevOps server, and then navigate to your project.
Select Artifacts, and then select your feed.
Select Connect to Feed, and then select NuGet.exe from the left navigation pane.
Follow the instructions in the Project setup section to connect to your feed.
Restore packages
Run the following command in your project directory to restore your packages:
nuget.exe restore