Connect to Azure Artifacts feeds (dotnet)
Azure DevOps Services | Azure DevOps Server 2022 | Azure DevOps Server 2020
Using Azure Artifacts, you can seamlessly publish your NuGet packages to Azure Artifacts feeds so you can share them with others privately or publicly based on your feed's visibility settings. This guide will walk you through setting up your project to authenticate with your Azure Artifacts feed using the dotnet command-line interface.
Prerequisites
An Azure DevOps organization and a project. Create an organization or a project if you haven't already.
An Azure Artifacts feed. Create a new feed if you don't have one already.
Download and install the Credential provider.
Download and install the .NET Core SDK (2.1.400+).
Connect to feed
Select Artifacts and then select your feed from the dropdown menu.
Select Connect to feed, and then select dotnet from the NuGet section.
Follow the instructions in the Project setup to set up your nuget.config file. The structure of your file should look similar to this:
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>
Sign in to your Azure DevOps collection, and then navigate to your project.
Select Artifacts, and then select your feed from the dropdown menu.
Select Connect to Feed, and then select dotnet from the left navigation pane.
Follow the instructions in the Project setup section to configure your nuget.config file and connect to your feed.
Authenticate NuGet Feed with Service Principal
To authenticate with a service principal, you must first install the Artifacts Credential Provider.
Set the ARTIFACTS_CREDENTIALPROVIDER_FEED_ENDPOINTS environment variable as shown below, specifying your feed URL, the service principal's application (client) ID, and the subject name or the file path of your service principal certificate. (Only one is needed between the certificate subject name or file path.)
In PowerShell, enter the following code.
$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>"
}
]
}
'@