Skip to content

Latest commit

 

History

History
172 lines (106 loc) · 7.78 KB

nuget-exe.md

File metadata and controls

172 lines (106 loc) · 7.78 KB
title description ms.assetid ms.service ms.topic ms.date monikerRange recommendations
Connect to a feed - NuGet.exe
How to connect to an Azure Artifacts feed - NuGet.exe
10665DBC-846E-4192-8CAB-D5A4C6E40C65
azure-devops-artifacts
conceptual
10/27/2023
<= azure-devops
true

Connect to Azure Artifacts feeds (NuGet.exe)

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

Azure Artifacts allows developers to both publish and download NuGet packages from various sources, including feeds and public registries. You can use it to privately share packages with your team or specific users and also make them publicly accessible, allowing you to share them openly with anyone on the internet. This article will guide you through the process of connecting to your Azure Artifacts feed.

Prerequisites

Project setup

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

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

  4. If this is your first time using Azure Artifacts with NuGet.exe, make sure you've installed the prerequisites, otherwise select Get the tools in the top-right corner to install them.

  5. Add a nuget.config file to your project, and place it in the same folder as your .csproj or .sln file. Paste the following snippet into it, and be sure to replace the placeholders with the appropriate values specific to your scenario:

    • 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>
    • 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>

::: moniker-end

::: moniker range="tfs-2018"

  1. Navigate to your project http://ServerName:8080/tfs/DefaultCollection/<ProjectName>.

  2. Select Build and Release, and then select Packages.

  3. Select your feed from the dropdown menu, and then select Connect to feed.

    :::image type="content" source="../media/connect-to-feed.png" alt-text="Screenshot showing the connect to feed button in TFS":::

  4. Select NuGet from the left panel. Make sure you've installed the prerequisites if this is your first time using Azure Artifacts with NuGet.exe, otherwise select Get the tools to download and install them.

  5. Run the command highlighted in step number two (2) to add your feed source URL to your nuget.config file.

    :::image type="content" source="../media/nugeturl.png" alt-text="A screenshot showing how to connect to your feed with NuGet in TFS.":::

::: moniker-end

Important

Azure Artifacts Credential Provider requires NuGet 4.8.0.5385 or later. Azure Artifacts recommends using NuGet version 5.5.x or later as it includes crucial bug fixes related to cancellations and timeouts.

::: moniker range="azure-devops"

Legacy project setup

If you're using an older version of NuGet, follow the instructions below to connect to your feed:

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

  4. Copy your source URL, and then replace /v3/index.json with /v2. Your updated source URL should resemble the following:

    • Project-scoped feed:

      https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/nuget/v2
      
    • Organization-scoped feed:

      https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/_packaging/<FEED_NAME>/nuget/v2
      
  5. Create a Personal Access Token, and make sure you scope it to the right organization you want to access and select one of the following scopes: Packaging (read), Packaging (read and write), or Packaging (read, write, and manage).

  6. Run the following command in a command prompt window to add your feed source to your nuget.config file:

    nuget sources add -name <FEED_NAME> -source <SOURCE_URL> -username <ANY_STRING_BUT_NOT_NULL> -password <YOUR_PERSONAL_ACCESS_TOKEN>
  7. If your organization is connected to Microsoft Entra ID, you must first authenticate with your AD credentials and then add your personal access token using the setapikey command:

    nuget sources add -name <FEED_NAME> -source <SOURCE_URL> -username <AZURE_ACTIVE_DIRECTORY_USERNAME> -password <AZURE_ACTIVE_DIRECTORY_PASSWORD>
    
    nuget setapikey <YOUR_PERSONAL_ACCESS_TOKEN> -source <SOURCE_URL> 

::: moniker-end

::: moniker range="tfs-2018"

Legacy project setup

If you're using an older version of NuGet, follow the instructions below to connect to your feed:

  1. Navigate to your project http://ServerName:8080/tfs/DefaultCollection/<ProjectName>.

  2. Select Build and Release, and then select Packages.

  3. Select your feed from the dropdown menu, and then select Connect to feed.

    :::image type="content" source="../media/connect-to-feed.png" alt-text="A screenshot of the connect to feed button in TFS.":::

  4. Select NuGet, and then copy your source URL. Replace /v3/index.json with /v2.

    :::image type="content" source="../media/nuget-consume-url.png" alt-text="A screenshot showing where to find the source URL in TFS.":::

  5. Create a Personal Access Token, and make sure you scope it to the right organization you want to access and select one of the following scopes: Packaging (read), Packaging (read and write), or Packaging (read, write, and manage).

  6. Run the following command in a command prompt window to add your feed source to your nuget.config file:

    nuget sources add -name <FEED_NAME> -source <SOURCE_URL> -username <ANY_STRING_BUT_NOT_NULL> -password <YOUR_PERSONAL_ACCESS_TOKEN>
  7. If your organization is connected to Microsoft Entra ID, you must first authenticate with your AD credentials and then add your personal access token using the setapikey command:

    nuget sources add -name <FEED_NAME> -source <SOURCE_URL> -username <AZURE_ACTIVE_DIRECTORY_USERNAME> -password <AZURE_ACTIVE_DIRECTORY_PASSWORD>
    
    nuget setapikey <YOUR_PERSONAL_ACCESS_TOKEN> -source <SOURCE_URL> 

::: moniker-end

Related articles