Select Page

In this blog post, I will show you how to build and run a C# application in Azure DevOps Pipelines.

Estimated reading time: 3 minutes

What Are Azure Pipelines?

Azure Pipelines is a cloud service from Microsoft Azure that automates the process of building, testing, and deploying code for applications and infrastructure. It supports a wide variety of programming languages such as .NET, Python, Node.js, PowerShell, Terraform, and more.

Some key features of Azure Pipelines include:

  • Continuous Integration (CI): Automatically build and test your code on every commit or trigger a manual build.
  • Continuous Deployment (CD): Deploy applications and infrastructure to public or private clouds.
  • Multi-platform support: Azure Pipelines supports the building and deployment of applications on Windows, Linux, and macOS.

In this post, we’ll focus on how to use Azure Pipelines to build a C# .NET application.

Step 1: Build the Console Application

To deploy a .NET application to Azure Pipelines, you can use an existing application or create a new console application using the following .NET CLI command:

Once the application is created, push the code to a repository that’s connected to your Azure DevOps project. In this case, I am using Azure Repos.

Step 2: Create a YAML Pipeline

Azure Pipelines uses YAML (Yet Another Markup Language) pipelines to define the workflow for building and deploying applications. Below is a sample pipeline that builds a .NET application using the built-in .NET integration.

Make sure to replace the .NET SDK version and project name according to your application. If your application uses a solution, change the project path to your solution name (with .sln extension).

Once done, push the code changes to your repository.

Step 3: Create a New Pipeline

From the Azure DevOps console, follow these steps to create a new pipeline:

  1. Go to the Pipelines section.
  2. Click on New pipeline.
  3. Select your repository from the list.
  4. Choose the Existing Azure Pipelines YAML file option.
  5. Select the branch and path to the YAML pipeline file.

After that, click Save and Run to build and run the application.

Pipeline Execution Overview

Once the pipeline runs, it will go through several steps to build and run your .NET application:

  • Install the latest .NET SDK on the agent (in this case, Ubuntu Linux).
  • Restore all required dependencies for the application.
  • Build the project and get it ready for execution.
  • Run the program.

Summary

In this post, we covered how to create and run a C# .NET console application using Azure Pipelines on a Linux agent. By utilizing YAML pipelines, you can easily set up the automated building, testing, and deployment of your .NET application.


Discover more from CPI Consulting Pty Ltd Experts in Cloud, AI and Cybersecurity

Subscribe to get the latest posts sent to your email.