Document

SUBSCRIBE TO GET FULL ACCESS TO THE E-BOOKS FOR FREE 🎁SUBSCRIBE NOW

Professional Dropdown with Icon

SUBSCRIBE NOW TO GET FREE ACCESS TO EBOOKS

Azure DevOps - Azure pipeline using Github

Github repository also can be connected with the Azure pipeline. You need to auth

Follow the below steps to connect the azure pipeline with Github Repo.

1. Create an asp.net core project in VS [Visual Studio] ( You can use any programming language or any other IDE).

2. Add project solution in a local git repository. In VS, right-click on Solution and Add to source control, and provide the Github credentials and Repository name which you want to create in Github (say mySourceCode).

3. Repository should be created in your Github Account.

4. Login to Azure DevOps and click on Azure pipeline and click on Create Pipeline button.

5. Select Repository source as Github

6. Select the Repository mySourceCode.

7. Provide the Repository Access to the Azure pipeline for mySourceCode Repository by clicking on Approve and Install button.

8. Provide Azure DevOps credentials and select the organization and the project which you want to connect with the Azure pipeline.

9. Authorize Azure pipeline by Clicking on Authorize Azure Pipelines button.

10. Select the pipeline build platform (Aspnet core) .NET Framework

11. Write the pipeline code similar to the given below

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
 
# Trigger indicates that whenever there is a change in the master branch then
# this pipeline will be executed automatically
trigger:
master
 # VM image is windows latest
pool:
  vmImage: ‘windows-latest’
 # variables are defined whichare used in the tasks
variables:
  solution: ‘**/*.sln’
  buildPlatform: ‘Any CPU’
  buildConfiguration: ‘Release’
 # job with multiple steps and steps are furhter having one or multiple tasks
 # NuGetToolInstaller@1 it is inbuilt step to download NuGet tool on the VM
 # NuGetToolInstaller@2 it is inbuilt step to Configure the NugetCommand for the solution (defined as variable)
 # VSBuild@1 to build the solution using MSBuild with given parameters
steps:
task: NuGetToolInstaller@1
 
task: NuGetCommand@2
  inputs:
    restoreSolution: ‘$(solution)’
 
task: VSBuild@1
  inputs:
    solution: ‘$(solution)’
    msbuildArgs: ‘/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation=”$(build.artifactStagingDirectory)\WebApp.zip” /p:DeployIisAppPath=”Default Web Site”‘
    platform: ‘$(buildPlatform)’
    configuration: ‘$(buildConfiguration)’

11. Save and run the pipeline.

Note: Saving will commit azure-pipelines.yml to the repository.
Share your love

Leave a Reply

Your email address will not be published. Required fields are marked *