/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; restore NuGet packages from the Telerik NuGet server, and activate your Kendo UI license in a CI workflow.

Table of Contents

CI Systems

System CI/CD file(s)
GitHub Actions .github/workflows
GitLab CI/CD .gitlab-ci.yml
Azure DevOps - Classic click a build badge
Azure DevOps - YAML azure-pipelines.yml

Badges

Project Azure DevOps GitHub Actions GitLab CI
ASP.NET AJAX Build CLASSIC Build AJAX Application
ASP.NET Core Build - CLASSIC Build ASP.NET Core Application n/a
ASP.NET Blazor Build - CLASSIC Build Blazor Application Build status
WPF (net48) Build - CLASSIC Build WPF Build status
WinForms (net48) Build - CLASSIC Build WinForms
Console Build - YAML Build Console Build status
UWP Build - YAML Build - CLASSIC
.NET MAUI Build - CLASSIC MAUI main
Xamarin.Forms Build - CLASSIC Build Xamarin.Forms Applications
Kendo Angular Build - CLASSIC Build Angular Build status
AppCenter Project Main Branch
Xamarin.Forms iOS iOS
Xamarin.Forms Android Android

Cool Notes

  • workflows/main_build-aspnetcore.yml uses a Dockerfile to build and publish a Linux image to DockerHub => lancemccarthy/myaspnetcoreapp
  • The Console, AJAX, Blazor and UWP projects are built using both AzDO Classic and YAML pipelines.

Videos

Azure DevOps with Telerik 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: 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 '${{ secrets.MyTelerikEmail }}' --password '${{ secrets.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

Using Telerik NuGet Keys

You can use the same approach in the previous section. Everything is exactly the same, except you use api-key for the username and the NuGet key for the password.

Please visit the Announcing NuGet Keys blog post for more details how ot create the key and how to use it.

dotnet nuget update source "Telerik" --source "https://nuget.telerik.com/v3/index.json" --configfile "src/nuget.config" --username 'api-key' --password '${{ secrets.MyNuGetKey }}' --store-password-in-clear-text

IMPORTANT: Protect your key by storing it in a GitHub Secret, then use the secret's varible name in the command