/DevOpsExamples

A repo to show you how to use a private NuGet feed, such as Telerik, to restore packages in Azure DevOps, GitHub Actions, GitLab CI and AppCenter.

Primary LanguageC#MIT LicenseMIT

DevOps - Pipeline and Workflow Examples

This repository contains a rich set of CI-CD demos that show you how to use Azure DevOps and GitHub Actions to build your Telerik and Kendo powered applications in the following systems.

System CI/CD file(s) Status
Azure DevOps azure-pipelines.yml Azure badges
GitHub Actions .github/workflows Actions badges
GitLab CI/CD .gitlab-ci.yml GitLab badges
AppCenter n/a AppCenter badges

These examples show you how to:

  • Authenticate and restore NuGet packages from the Telerik NuGet server.
  • Activate your Kendo UI Angular/React/Vue license in your CI workflow.

Build Statuses

The following tables list the status badges for the various pipelines and workflows. To keep things organized, each CI system has its own table.

Azure DevOps

Project Main Branch Pipeline type
ASP.NET Blazor (.NET 6) Build status classic
WPF & WinForms (.NET Framework) Build status classic
Console (.NET 6) Build Status yaml
.NET MAUI Build MAUI classic
Xamarin.Forms Build Xamarin.Forms classic
Angular Build Angular classic
React Build Kendo React classic
Vue Build Kendo Vue classic

GitHub Actions

Project Branch: main
ASP.NET Blazor (.NET 6) Build Web
WPF (.NET Framework) Build WPF
WinForms (.NET Framework) Build WinForms
Console (.NET 6) Build Console
.NET MAUI MAUI main
Angular Build Angular
React Build React
Vue Build Vue Application

GitLab CI-CD

Project Main Branch
ASP.NET Blazor (.NET 5) Build status
WPF (.NET Framework) Build status
Console (.NET 5) Build status
Angular Build status
React Build status
Vue Build status

Microsoft AppCenter

Project Main Branch
Xamarin.Forms iOS iOS
Xamarin.Forms Android Android

In AppCenter build settings, you set the environment variables defined in the nuget.config, TELERIK_USERNAME and TELERIK_PASSWORD. If the build is for Kendo, then you set the KENDO_UI_LICENSE environment variable.

Videos

Azure DevOps with Private NuGet Server

The following 4 minute video takes you though all the steps on adding a private NuGet feed as a Service Connection and consuming that service in three different pipeline setups.

YouTube tutorial

  • 0:09 Add a Service connection to the Telerik server
  • 1:14 Classic pipeline for .NET Core
  • 1:47 Classic .NET Framework pipeline
  • 2:25 YAML pipeline setup for .NET Core

Tips and Troubleshooting

GitHub Actions: Using Secrets to Set Environment Variables

A common problem to run into is to think that the environment variable is the same thing as the GitHub Secret (or Azure DevOps pipeline variable). In this demo, I intentionally named the secrets a different name than the environment variable name so that it is easier for you to tell the difference.

However, I know that not everyone has the time to watch the video and just copy/paste the YAML instead. This will cause you to hit a roadblock because you missed the part about setting up the GitHub secret, Azure DevOps pipeline variable or . Here is a 2 screenshot crash-course on how to get back on track.

In your YAML, you probably have done this:

image

That mean you must also have the secrets in your Settings > Secrets list

image

Powershell: Restore Packages

If your nuget.config has a packageSourceCredentials section that uses environment variables for the values, you can also use Powershell to set those env variables using the pipeline secrets variables, than manually invoke the package restore.

# 1. Set the Env Variables being used in the nuget.config credentials using pipeline secrets (e.g., $(MyTelerikEmail) is a secret)
$env:TELERIK_USERNAME = '$(MyTelerikEmail)'
$env:TELERIK_PASSWORD ='$(MyTelerikPassword)'

# 2. Set the project file path and nuget.config file path
$myBlazorProjectFilePath = 'src/Web/MyBlazorApp/MyBlazorApp.csproj'
$myNugetConfigFilePath = 'src/nuget.config'

# 3. Restore the Telerik and nuget.org packages using the nuget.config file
dotnet restore $myBlazorProjectFilePath --configfile $myNugetConfigFilePath --runtime win-x86

# 4. Clear those variables when done (not required, but good practice)
$env:TELERIK_USERNAME = ''
$env:TELERIK_PASSWORD =''

Powershell: Update Package Source Dynamically

You could also dynamically update the credentials of a Package Source defined in your nuget.config file This is a good option when you do not want to use a packageSourceCredentials section that uses environment variables.

# Updates a source named 'Telerik' in the nuget.config
dotnet nuget update source Telerik --source https://nuget.telerik.com/v3/index.json --configfile src/nuget.config --username '$(MyTelerikEmail)' --password '$(MyTelerikPassword)' --store-password-in-clear-text

That command will look through the nuget.config for a package source with the key Telerik and then add/update the credentials for that source.

The --store-password-in-clear-text switch is important. It does not mean the password is visible, rather it means that you're using the password text and not a custom encrypted variant. For more information, please visit https://docs.microsoft.com/en-us/nuget/reference/nuget-config-file#packagesourcecredentials