Skip to content

Latest commit

 

History

History
121 lines (85 loc) · 4.76 KB

dotnet-setup.md

File metadata and controls

121 lines (85 loc) · 4.76 KB
title description ms.service ms.custom ms.topic ms.date monikerRange recommendations
Connect to Azure Artifacts feeds - dotnet
Learn how to connect to Azure Artifacts feeds - dotnet
azure-devops-artifacts
devx-track-dotnet
how-to
04/09/2025
>= azure-devops-2020
true

Connect to an Azure Artifacts feed (dotnet)

[!INCLUDE version-gt-eq-2020]

Azure Artifacts enables developers to seamlessly publish packages to feeds and share them privately or publicly, depending on the feed’s visibility settings. This guide walks you through setting up your project and authenticating with your Azure Artifacts feed.

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.
- Download and install the .NET Core SDK.

Connect to a feed

::: moniker range="azure-devops"

  1. Select Artifacts and then select your feed from the dropdown menu.

  2. Select Connect to feed, and then select dotnet from the NuGet section.

  3. Add a nuget.config file to your project. Place it in the same folder as your .csproj or .sln file, and paste the snippet provided in the Project setup section into it. Your nuget.config file should look similar to the following:

    • Project-scoped feed:

      <?xml version="1.0" encoding="utf-8"?>
      <configuration>
        <packageSources>
          <clear />
          <add key="<FEED_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="<FEED_NAME>" value="https://pkgs.dev.azure.com/<ORGANIZATION_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 collection, 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 dotnet from the left.

  4. Add a nuget.config file to your project. Place it in the same folder as your .csproj or .sln file, and paste the snippet provided in the Project setup section into it.

    :::image type="content" source="../media/connect-to-feed-dotnet-server-2020-and-2022.png" alt-text="A screenshot displaying how to connect to a feed in Azure DevOps Server 2020 and 2022.":::

::: moniker-end

Authenticate using Service Principals

You can use a service principal to authenticate with your Azure Artifacts feed. To do this, set the ARTIFACTS_CREDENTIALPROVIDER_FEED_ENDPOINTS environment variable as shown below.

This variable should define the feed URL, the service principal’s application (client) ID, and either the certificate subject name or the path to the certificate file (only one of these two is required).

$env:ARTIFACTS_CREDENTIALPROVIDER_FEED_ENDPOINTS = @'{
    "endpointCredentials": [
        {
            "endpoint": "<FEED_URL>",
            "clientId": "<SERVICE_PRINCIPAL_APPLICATION_(CLIENT)_ID>",
            "clientCertificateSubjectName": "<SERVICE_PRINCIPAL_CERTIFICATE_NAME>",
            "clientCertificateFilePath": "<SERVICE_PRINCIPAL_CERTIFICATE_PATH>"
        }
    ]
}
'@
export ARTIFACTS_CREDENTIALPROVIDER_FEED_ENDPOINTS='{
    "endpointCredentials": [
        {
            "endpoint": "<FEED_URL>",
            "clientId": "<SERVICE_PRINCIPAL_APPLICATION_(CLIENT)_ID>",
            "clientCertificateSubjectName": "<SERVICE_PRINCIPAL_CERTIFICATE_NAME>",
            "clientCertificateFilePath": "<SERVICE_PRINCIPAL_CERTIFICATE_PATH>"
        }
    ]
}'

Related content