Skip to content

Azure Devops – ASPDotNet

SYNOPSIS:

Following is the guide to host a ASP.NET web application on Azure Devops [ Formerly VSTS ]. The guide will demonstrate the Devops Build, Release and Deployment pipeline using the Azure Devops platform.

TOOLS USED:

  • Azure Devops
  • Git
  • Sublime Text 3
  • Cmder
  • Powershell
  • Windows 10 Enterprise

STEP-01: Local Machine Setup

02

STEP-02: Once the project is pushed to VSTS git 

00

STEP-03: Project description and Overview,

01

  1. Select the overview from the left sidebar
  2. Describes the project
  3. The language the project is using
  4. the status of the build pipeline
  5. the stats of the project, describing how many commits have been made, pull request and success rate of the pipeline and the deployments
  6. Members involved in the project

 

STEP-03: Repository Information

03

  1. Select the Repo from left sidebar
  2. select the project from the first right pane, shows the folder and file structure
  3. The right pane gives the last modified date for each folder/file and its corresponding short SHA-1 key from git commits

 

STEP-04: VSTS Agent Setup

04

Here, we shall configure a self Hosted VM for build process. To do so we need to configure a Agent.

  1. Go to organization settings
  2. Select the Agent Pool configuration
  3. Download the Agent and follow the instructions to host a agent on the VM
  4. Once successfully configured, Agent appears on the Agent Pool, select the agent
  5. The build triggered using the agent and the agent capabilities can be seen and modified

 

STEP-05: Build Pipeline Setup

05

  1. Select Pipelines from left pane
  2. Click on the Build pipeline
  3. Select the Tasks Tab
  4. Click on the Pipeline, to modify the settings
  5. Name the Build Pipeline
  6. Select the Agent from the Pool which was created in STEP-04: 03
  7. Parameters for the pipeline – select the solution file from project
  8. Name the Artifacts directory where the final artifacts will be stored

 

STEP-06: Build Pipeline – Source Information

06

  1. Select the pipeline option from left pane
  2. Choose build pipeline
  3. From the tasks, select the Get Sources
  4. Select the Azure Repo Git option since our project is under Git VCS
  5. Select the project from drop-down
  6. select the respective repository
  7. select the default branch for the build pipeline
  8. Before every build is triggered, make sure the build directory is clean

 

STEP-07: Build Pipeline – Agent Details

07

  1. Select the Pipeline option from left sidebar
  2. Click on the Build pipeline
  3. From the Tasks Pane select the Run on Agent
  4. Enter name for the build agent
  5. Select the build agent form the pool which was created earlier in STEP-04: 03

 

STEP-08: Build Pipeline – NuGet Task

08

  1. Select the Pipeline option from left sidebar
  2. Click on the Build pipeline
  3. From the Tasks Pane select the Use NuGet task
  4. Name the task
  5. select the version of NuGet to use

 

STEP-09: Build Pipeline – Restore NuGet Packages Task

09

  1. Select the Pipeline option from left sidebar
  2. Click on the Build pipeline
  3. From the Tasks Pane select the NuGet Restore to restore the dependencies
  4. Enter the name for the Task
  5. Nuget restore commands
  6. Verify that the right solution file is selected
  7. Select the option to use the packages form Nuget.org repository

 

STEP-10: Build Pipeline – Build Solution

10

  1. Select the Pipeline option from left sidebar
  2. Click on the Build pipeline
  3. From the Tasks Pane select the Build Solution task
  4. Name the task
  5. select the version of Visual Studio to use for the build
  6. Pass the command line arguments for the build
  7. use the default settings for the platform
  8. use the default configuration for this build.

 

STEP-11: Build Pipeline – Make Executable using makensis

11

  1. Select the Pipeline option from left sidebar
  2. Click on the Build pipeline
  3. From the Tasks Pane select the Powershell script task
  4. Name the task
  5. Select the inline powershell option and write inline PS1 to get the tag version from the git tags and extract the tag and pass it to the makensis to use it as the PRODUCT VERSION during the exe build
  6. Error action preference is set to silentlycontinue to ignore any errors and silently continue

 

STEP-12: Build Pipeline – Publish Solution

12

  1. Select the Pipeline option from left sidebar
  2. Click on the Build pipeline
  3. From the Tasks Pane select the Build Solution task and modify it to publish solution
  4. Name the task
  5. verify the correct solution is selected
  6. select the appropriate visual studio version
  7. Pass the commandline options to publish arguments and include the default publish profile pubxml file
  8. select the default build platform
  9. select the default build configuration which came with the task
  10. make sure to clean the publish directory before publishing

 

STEP-13: Build Pipeline – Publish Artifacts

13

  1. Select the Pipeline option from left sidebar
  2. Click on the Build pipeline
  3. From the Tasks Pane select the to publish the build artifacts
  4. name the task
  5. select the source directory where the build artifacts are stored
  6. verify the artifacts drop directory which was created in STEP-05: 05
  7. select the azure pipeline artifacts to publish

 

STEP-14: Build Pipeline – Build Variables

14

  1. Select the Pipeline option from left sidebar
  2. Click on the Build pipeline
  3. Select the variables Tab
  4. select the pipeline variables
  5. you can pass the dynamic build variables in the key:value pair format

 

STEP-15: Build Pipeline – Build Triggers

15

  1. Select the Pipeline option from left sidebar
  2. Click on the Build pipeline
  3. Select the Triggers Tab
  4. Select the Project from the Triggers tab
  5. Enable Continuous Integration for the project
  6. Trigger refs/tags/v* will trigger a build if a tag is pushed
  7. Trigger dev will trigger a build if the code is pushed to dev branch
  8. Trigger master will trigger a build if the code is pushed to master branch

 

STEP-16: Build Pipeline – Build History

This will display all the build which were triggered manually and using the CI pipeline

16

  1. Select the Pipeline option from left sidebar
  2. Click on the Build pipeline
  3. Select the project
  4. Select the History to see the entire build history

 

STEP-17: release Pipeline – SetUp

17

  1. Select the Pipeline option from left sidebar
  2. Click on the Release pipeline
  3. Select the Edit pipeline and select the Artifacts option
  4. create a empty stage to deploy to QA
  5. create a empty stage to deploy to Stage
  6. create a empty stage to deploy to PROD

 

STEP-18: Release Pipeline – Artifacts Options

releasePipeline

  1. select the Build option
  2. Select the Project to setup the release pipline
  3. source for the release will be the build pipeline project
  4. Default version will be set to a specific branch and git tags
  5. Default branch to trigger the release will be dev
  6. tag reference for release using tags will be refs/tags/v*
  7. Set appropriate alias to identify the release
  8. click Add to set the above options

 

STEP-19: Release Pipeline – Artifacts Triggers

18

  1. Select the Pipeline from the Left sidebar
  2. select the release pipeline
  3. Select the trigger option from the Artifacts block
  4. Enable the continuous deployment option
  5. Enter the reference tags refs/tags/v* to trigger the deployment after successful build
  6. enter the git branch for which to trigger the deployment
  7. Enable Pull Request trigger so that if a pull request is made and code is merged, we can build and release the artifact automatically
  8. master branch is used for pull request trigger, when code is merged on to master branch then build and release is triggered
  9. stages where the pull request trigger is confirmed is stated here

 

STEP-20: Release Pipeline – Deploy to QA

19

  1. Select the Pipeline from the Left sidebar
  2. select the release pipeline
  3. Select the Deploy to QA stage trigger
  4. select the after release trigger to trigger deployment after release
  5. select dev branch trigger so only code pushed to dev will be deployed to QA servers

 

STEP-21: Release Pipeline – Deploy to Stage

20

  1. Select the Pipeline from the Left sidebar
  2. select the release pipeline
  3. Select the Deploy to Stage servers trigger
  4. select the after release trigger to trigger deployment after release
  5. select the refs/tags/v* to deploy the artifacts when the tag is pushed
  6. make sure to save

 

STEP-22: Release Pipeline – Deploy to Stage – Tasks

21

  1. Select the Deploy to Stage task for the Release pipeline
  2. select the tasks tab
  3. add a copy files task to copy the artifacts to a particular location on the server
  4. name the task
  5. select the source, which will be the SdArtifacts directory created in STEP-05:05
  6. parse the source folder to select only exe files
  7. select the target folder on the staging server

 

STEP-23: Release Pipeline – Deploy to PROD

22

  1. Select the Pipeline from the Left sidebar
  2. select the release pipeline
  3. Select the Deploy to PROD servers trigger
  4. select the after release trigger to trigger deployment after release
  5. Enable filters
  6. select the master branch
  7. enable the pull request trigger to trigger the deployment using a pull request

 

STEP-24: Release Pipeline – Finished Pipeline

24

  1. Select the Pipeline from the Left sidebar
  2. select the release pipeline
  3. select a release pipeline
  4. shows the continuous deployment for the release pipeline
  5. Based on the trigger conditions deployments were triggered and deployed to stage
  6. Deploy to stage tasks were executed and artifacts were copied to target directory
  7. Based on the trigger conditions deployments were triggered and deployed to PROD

Shashi View All

-== Superman ==-

One thought on “Azure Devops – ASPDotNet Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: