Saturday, March 26, 2022

Azure Repos With Visual Studio Code

 Visual Studio is a Microsoft tool to develop applications in different programming languages like .NET, python,nodeJs, Angular, etc. You can connect Github or Azure Repo to your application code and maintain the version of your code directly with VS.

There are different VS editions are available on Microsoft (VS Download)

You can download the community edition for free or other editions for the 6-month trial version.

VS with Github.

Step 1: Open Visual Studio.

Step 2: Click on Create a new project.

Step 3: Select Core Web App project with c# and click on Next Button.

Step 4: Project Name: CoreWebApp and Click on Next Button.

Step 5: Target framework: .Net 5.0(current) and Click on Create button.

Step 6: A default project with some cshtml code should be created.

Step 7: Goto Git Menu ---> Create a Git Repository Option

Step 8: Select your Github account and Provide the Repoisitory Name: CoreWebApp.

Step 9: UnCheck the Private Repository option.

Step 10: Click on Create and Push Repository button.

Step 11: Provide the Initial commit and click on Commit All button.

Step 12: Check Github account there you will find a repo name CoreWebApp and it includes your project code.

Step 13: Make some changes in the code and Select Git--->Commit or Stash and provide a message for the commit and click on Commit All.

Step 14: Select Git--> Push option.Check in the Github Repo.

Creating a new Branch using VS in Github

Step 1: Goto Git--->New Branch and provide the branch name say Feature1 Select Checkout Branch Option and Click on Create Button.

Step 2: Goto GitChanges and Click on Push button to Push the code of new branch to Github.

Step 3: Make some changes in the feature branch code and commit and push again and you will find that in the Github repo feature branch changes are reflected.

Clone a project from Github Repo to VS

Step 1: Open VS and select the Clone a Repo button.

Step 2: Provide Github URL in Repository Location and Click on Create button.

Step 3: You will find the code is reflected in VS.

VS with Azure Repos

Azure Repos can be attached to VS in the same way as Github, the only difference is to use Azure Repos URL instead of Github Location. Use the following steps in case you want to add Azure Repos.

Step 1: Create a new Repo in Azure DevOps Project let's call it CoreWebApp

Step 2: Open existing project in VS and goto Git--->Manage Repos

Step 3: Git Repository Settings--->Remotes and Click on Edit button.

Step 4: Add Azure Repo HTTPS URL.

Step 5: Push the changes to Azure Repos by using push operations in VS.

Step 6: Select Another branch and perform the push operation so that it can push the changes related to the feature branch as well.

Import Github Repo to Azure Repo

Github Repos can be imported into the Azure Repos if required.

Step 1: On the drop-down list of Repos you can select the Import repository option

Step 2: Select Repository Type as Git and in clone URL enter Github Repo URL and provide the name of the repository and click on import button.

Step 3: The repository should be imported from Github.

Connect Github Repo to Azure Boards

Step 1: Select Project Settings 

Step 2: Select Boards and Github Connection 

Step 3: Click on Connect to Github Connection then Add the Github Repository CoreWebApp.

Step 4: Click on Approve and Install button.

Step 5: In the Boards connection you can find the Github Repo connection in the list.

Step 6: Goto Github account and CoreWebApp Repo and Goto Settings and Integration and Github Apps and you can see that the Azure Board app is added.

Step 7: Let's create a task in the Azure Repo and add a task and note down the task number(consider task number is 15).

Step 8: Goto Github Repo and Make the changes in your code and in the commit mention Fixed AB#15 where 15 is the number for the Azure Board task. AB


Post a Comment