Tuesday, November 9, 2021

Visual Studio 2022 and CI/CD Using GitHub Actions Workflows

Finally Visual Studio 2022 (the first-ever 64-bit version of Visual Studio) is released with great features, such as Hot Reload for .NET and C++ (Web, WPF, Windows Forms, you name it), cross-platform testing, etc.

In this post let's see the seamless integration Visual Studio 2022 provides with GitHub actions.

I have a repo hosted in GitHub and I wanted to enable CI/CD to deploy to an Azure App Service. I can do that with very few steps and even without leaving Visual Studio. Let's see how. 

First I am right-clicking on the project and selecting Publish.
Publish
Then it's just following the steps in the wizard. I am including all the steps, so we kind of have a complete guide.

I am deploying to Azure App Service. I am selecting Azure and Clicking on Next.
Azure
I already have a Linux Azure App Service which I am going to use. So I am selecting Azure App Service (Linux) and clicking on Next.
Azure App Service (Linux)
I am selecting my target App Service and clicking on Next.
Select the App Service
I am not going to be using any API Management, so I am skipping this step and going to Next.
API Management - Skipping
Now comes the interesting step. Visual Studio identifies my repo is on GitHub and gives me an option to add GitHub Actions.
CI/CD using GitHub Actions workflows (generated yml file)
So I am going ahead with selecting CI/CD using GitHub Actions workflows (generated yml file) and that's mostly it. 
Workflow File Created and Ready to Push
Visual Studio has already created the workflow yml file with the publishing profile saved as an Action secret. Now I just need to commit and push the changes to remote.
CI/CD
And that is super easy. 

I have this image from back in 2012, it's so true.
Do more of what you love
If you haven't started using Visual Studio 2022, do it now.

You can find the sample code here,

Happy Coding.

Regards,
Jaliya

No comments:

Post a Comment