Skip to content

Latest commit

 

History

History
100 lines (63 loc) · 4.01 KB

File metadata and controls

100 lines (63 loc) · 4.01 KB
title Restore NuGet packages with the NuGet CLI
description Learn how to connect to your feed and restore NuGet packages using the NuGet CLI.
ms.service azure-devops-artifacts
ms.topic tutorial
ms.date 01/14/2025
monikerRange <= azure-devops

Restore NuGet packages from the command line (NuGet.exe)

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

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 the Azure Artifacts Credential Provider.
- The latest NuGet version.

Connect to a feed

::: moniker range="azure-devops"

  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 Connect to feed, and then select NuGet.exe from the left navigation pane.

  4. 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>

::: moniker-end

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

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

  2. Select Artifacts, and then select your feed.

  3. Select Connect to Feed, and then select NuGet.exe from the left navigation pane.

  4. Follow the instructions in the Project setup section to connect to your feed.

::: moniker-end

::: moniker range="azure-devops-2019"

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

  2. Select Artifacts, and then select your feed.

  3. Select Connect to Feed, and then select NuGet from the left navigation pane.

  4. Follow the provided instructions to add your package source URL to your nuget.config file.

::: moniker-end

Restore packages

Run the following command in your project directory to restore your packages:

nuget.exe restore

Related content