Article Header

Learn how to use the Telerik NuGet server, or NuGet packages with Azure Artifacts, in an Azure DevOps build pipeline.

As a Support Engineer, I frequently come across questions on how to use the Telerik NuGet server in Azure DevOps build pipelines. Since our NuGet server is a private feed that requires credentials, this can be confusing to set up the first time.

Let me help demystify this today by showing you two options you can use to restore Telerik NuGet packages in your build definitions.

  • A Service Connection
  • Azure Artifacts

Let's start with the more traditional approach and use the Service Connection and a nuget.config file to connect to the Telerik NuGet server to restore packages. Then, I'll explain how you host your own Telerik NuGet package(s) in an Azure Artifacts feed and restore packages from there instead.

Package Sources

In Visual Studio, you would add a private NuGet feed by going into the Tools > Options > NuGet > Package Sources and add a Package Source.

Visual Studio Package Sources

Visual Studio will prompt you for your Telerik credentials the first time the feed is accessed. These credentials can be later accessed via the Windows Credentials tab in the Credential Manager app (e.g. to update password).

Credentials Manager interface with Windows credentials selected and Telerik list item visible.

However, what if your project is being built in an Azure DevOps build pipeline? How does the pipeline restore a package that is only in a private feed? This is where a NuGet config file comes into play. It allows you to set package sources as well as where to get the credentials.

Below is an example of a nuget.config file. Notice that it defines the Telerik NuGet server URL as well as two environment variables for the credentials.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
  <packageSources>
    <add key="NuGet" value="https://api.nuget.org/v3/index.json" />
    <add key="Telerik" value="https://nuget.telerik.com/nuget" />
  </packageSources>
  <packageSourceCredentials>
    <Telerik>
      <add key="Username" value="%TELERIK_USERNAME%" />
      <add key="ClearTextPassword" value="%TELERIK_PASSWORD%" />
    </Telerik>
  </packageSourceCredentials>
</configuration>

However, this could be a security issue in a CI/CD environment where another user might be able to read the values of environment variables. This is where the Service Connection comes in handy.

The Azure DevOps Service Connection lets you enter credentials in a secure manner without unnecessarily exposing account details and that Service Connection can now be used by multiple pipelines to authenticate private NuGet feeds (and other services that need authentication).

Service Connection Walkthrough

Let's walk through adding a Service Connection to the Telerik NuGet server. To start, go to the Project Settings in your DevOps project portal.

Project Setting

On the Project Settings page, select the Service Connections menu item under Pipelines and then open the New Service Connection drop down.

New Service Connection drop down

Select NuGet from the drop-down list.

NuGet Service Selection

You'll be presented with a dialog that lets you enter the URL and authentication credentials. For the Telerik NuGet server, you'll want to select Basic Authentication.  Once that selection is made, you can enter the Telerik server URL and use your Telerik account credentials.

Add NuGet service connection information

Once that is saved, your build pipelines can now fetch packages from the Telerik NuGet feed. Next, let's take a look at how a build pipeline uses the nuget.config and the Service Connection together to fetch the Telerik packages.

Using Telerik Service Connection

In your build pipeline, there's a NuGet Restore step. Select that step and look to the properties panel. Change the Feeds to Use selection to Feeds in my NuGet.config. A new drop-down will appear titled "Credentials for feeds outside this organization/collection." Open it and select the newly available Telerik NuGet Service Connection.

Using Service Connection

That's it! When you queue and run the pipeline, the Telerik NuGet packages will be restored.

Azure Artifacts

Using a Service Connection means that any package or product available to that account holder could be fetched and used. If you do not want pipelines to have unfettered access to the Telerik account holder's downloads, you can host your own feed right in the DevOps project with the Azure Artifacts feature.

In the project's main menu, select Artifacts and then click the New Feed button at the top.

Artifacts Tab

Give the feed a name (e.g. TelerikPackages), select the "Only use packages published to this feed" option, then click the Create button. You will now have your own feed that you can push nupkg files to, or drag and drop on, and it will handle the heavy lifting of the server duties.

To see how to push packages to this feed, click the "Connect to feed" option at the top. A dialog will appear with helpful information on how you can push packages to that specific feed.

Connect to Azure Artifacts Feed

You can get the NuGet package file (nupkg) for any Telerik product you're using by going to the downloads page for that product. You can start at the My Account - All Products page.

Underneath the installer for the product, you'll see an Other Setup Files section where the nupkg files will be. For example, here's what it looks like for the Telerik Reporting packages.

Telerik Reporting NuGet package files

The last piece of this puzzle is to go to the build pipeline and select that feed for a NuGet Restore step.

Using an Artifact Feed

Just like we did above for the Service Connection, go to the build pipeline and select the NuGet Restore step. Except this time, you'd choose Feed(s) I select here and choose the TelerikPackages feed in the Use packages from this Azure Artifacts/TFS feed drop-down list.

Using the Artifact feed in a pipeline

Important: If you have nuget.org packages to restore in addition to the Telerik packages, leave the "Use packages from NuGet.org" option selected.

Wrapping Up

I hope this information helps show how you can use Telerik NuGet packages in your Azure DevOps pipelines. you can take Service Connection route or go with a more controlled Azure Artifacts option.

You can find more information on using Azure DevOps or Azure Artifacts in the following documentation:

If you have any questions, don't hesitate to reach out. I'm available on Twitter @lancewmccarthy. If you're having problems with, or have questions about, the Telerik packages, you can talk directly to the engineers for that product by opening a Support Ticket.

Thanks for stopping by and have a great day!


Lance McCarthy Profile Photo
About the Author

Lance McCarthy

Lance McCarthy is Team Lead - US DevTools Support and Principal Support Engineer at Progress. He is also a Microsoft MVP for Windows Development. He covers all Telerik DevCraft products, specializing in .NET desktop, mobile and web components.

Comments

Comments are disabled in preview mode.