CI/CD Pipeline for .NET Standard Framework Application using GitHub Action
๐ 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
- 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>
Create a GitHub repository for the application and push the code to the repository.
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
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.
Create AWS IAM credentials with sufficient permissions to deploy the application to Beanstalk, and store the credentials as GitHub secrets.
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