CI/CD Pipeline for .NET Standard Framework Application using GitHub Action

CI/CD Pipeline for .NET Standard Framework Application using GitHub Action

ยท

2 min read

๐Ÿš€ Introduction

In this tutorial, we will learn how to set up a CI/CD pipeline for a .NET Standard application using MSBuild, Windows Server, AWS Beanstalk, and GitHub Actions. We will create a GitHub repository for the application, set up a GitHub Actions workflow to build and publish the application using MSBuild, and deploy the package to AWS Beanstalk. Let's get started!

๐Ÿ”ง Prerequisites Before we begin, make sure you have the following:

  • An AWS account

  • A Windows Server instance on AWS EC2

  • MSBuild, .NET Core SDK, and AWS CLI installed on the Windows Server instance

  • A .NET Standard application created using Visual Studio or the dotnet new command

๐Ÿ“ Step-by-Step Guide

  1. Configure the application to use MSBuild for building and publishing the project. Add a Directory.Build.props file to the project directory with the following contents:
<Project>
  <PropertyGroup>
    <PublishDir>$(MSBuildProjectDirectory)\publish</PublishDir>
  </PropertyGroup>
</Project>
  1. Create a GitHub repository for the application and push the code to the repository.

  2. Set up a GitHub Actions workflow to build and publish the application using MSBuild. Here's an example workflow file:

name: Build and Publish

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v2

    - name: Setup MSBuild
      uses: microsoft/setup-msbuild@v1.0.2

    - name: Build and Publish
      run: msbuild /t:Publish /p:Configuration=Release

    - name: Deploy to AWSstalk
      uses: einaregilsson/beanstalk-deploy@v16
      with:
        aws_access_key: ${{ secrets.AWS_ACCESS_KEY }}
        aws_secret_key: ${{ secrets.AWS_SECRET_KEY }}
        region: us-east-1
        application_name: my-application
        environment_name: my-environment
        version_label: ${{ github.sha }}
        package: ./publish
  1. Set up the necessary AWS resources, including an Elastic Beanstalk application and environment, and configure the environment to use the appropriate platform and instance type.

  2. Create AWS IAM credentials with sufficient permissions to deploy the application to Beanstalk, and store the credentials as GitHub secrets.

  3. Test the workflow by pushing changes to the repository and verifying that the application is deployed to Beanstalk.

๐ŸŽ‰ Conclusion

Congratulations! You have successfully set up a CI/CD pipeline for a .NET Standard application using MSBuild, Windows Server, AWS Beanstalk, and GitHub Actions. With this pipeline in place, you can easily build, test, and deploy your application with confidence.

๐Ÿ‘‰ Checkout GitHub Repository for projects:

๐Ÿ”— github.com/sumanprasad007

Did you find this article valuable?

Support Prasad Suman Mohan by becoming a sponsor. Any amount is appreciated!

ย