Azure DevOps Build Pipeline | CI/CD | Create .Net Core Build Pipeline

3 min read 5 months ago
Published on Sep 01, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial guides you through creating a build pipeline in Azure DevOps for an ASP.NET Core MVC web application. Utilizing Continuous Integration and Continuous Deployment (CI/CD) practices, this guide is essential for developers looking to automate their build processes and ensure efficient deployment.

Step 1: Set Up Your Azure DevOps Account

  • Navigate to the Azure DevOps website and sign up for an account if you don't already have one.
  • Once logged in, create a new project by selecting the "New Project" button.
  • Fill in the project details, such as the name and description, and choose the visibility (public or private).

Step 2: Create a New Build Pipeline

  • Go to the "Pipelines" section from the left sidebar and click on "Builds."
  • Click on the "New Pipeline" button to start creating your build pipeline.
  • Select your code repository source (e.g., Azure Repos Git, GitHub, etc.) and authorize Azure DevOps to access your repository.

Step 3: Configure Your Pipeline

  • Choose the type of application you are building. For this tutorial, select "ASP.NET Core."

  • Azure DevOps will automatically suggest a YAML pipeline configuration. Review and modify the configuration as needed.

  • Here’s a sample YAML configuration for a .NET Core project:

    trigger:
      branches:
        include:
          - main
    
    pool:
      vmImage: 'windows-latest'
    
    steps:
      - task: DotNetCoreCLI@2
        displayName: 'Build with dotnet'
        inputs:
          command: 'build'
          projects: '**/*.csproj'
      - task: DotNetCoreCLI@2
        displayName: 'Test with dotnet'
        inputs:
          command: 'test'
          projects: '**/*.csproj'
    
  • Adjust the trigger and pool sections according to your project needs.

Step 4: Save and Run Your Pipeline

  • After configuring the pipeline, click "Save" to store your changes.
  • To test the pipeline, click on "Run" to initiate the build process.
  • Monitor the build process in the Azure DevOps interface. Ensure that all steps complete successfully.

Step 5: Set Up Continuous Deployment

  • After confirming your build pipeline works, navigate to the "Release" section within Azure DevOps.
  • Click on "New Pipeline" to create a release pipeline that will deploy your application.
  • Link the release pipeline to your build pipeline by selecting the artifact created in the build process.
  • Configure deployment stages, such as staging and production, based on your deployment strategy.

Conclusion

Creating a build pipeline in Azure DevOps for an ASP.NET Core MVC web app streamlines your development process through automation. By following these steps, you have set up a CI/CD pipeline that can help deliver high-quality software efficiently. For further learning, consider exploring additional Azure DevOps tutorials or experimenting with different deployment strategies to enhance your application’s delivery process.