Building a .NET Code Repository in Azure DevOps Using MS Build: Step-by-Step Guide


2 min read

Step 1: Set up Azure DevOps Project

  1. Go to and sign in with your Azure DevOps account.

  2. Click on "Create project" to create a new project or use an existing one.

Step 2: Create a New Git Repository

  1. In your Azure DevOps project, click on "Repos" in the left sidebar.

  2. Click on "Import" to import the public Git repository. Provide the repository URL and complete the import process.

Step 3: Set Up the Build Pipeline

  1. In your Azure DevOps project, click on "Pipelines" in the left sidebar.

  2. Click on "Create pipeline" to create a new pipeline.

  3. Select the repository you imported in Step 2 and choose the branch you want to build.

Step 4: Configure the Build Pipeline

  1. Azure DevOps will analyze your repository and suggest templates. Choose "Starter pipeline" or "Empty job" if you prefer to configure everything manually.

  2. You'll be directed to the pipeline editor.

Step 5: Define Build Steps

  1. Update VM Image: Replace the existing pool: vmImage: 'vs2017-win2016' section in your YAML with pool: vmImage: 'windows-latest'. By using the windows-latest VM image, your pipeline will always utilize the most current version of Windows available on Azure Pipelines. This ensures that your builds run on the latest infrastructure with the latest tools and updates.

  2. Switch to MSBuild: Replace the current VSBuild task with the MSBuild task to build your solution. MSBuild is a powerful build platform that offers improved performance and better support for modern projects. This switch will enable you to take advantage of the latest build capabilities and maximize the efficiency of your build process.

       vmImage: 'windows-latest'
       solution: './ClientLibrary/Samples/ClientSamples.sln'
       buildPlatform: 'Any CPU'
       buildConfiguration: 'Release'
     - task: NuGetToolInstaller@0
     - task: NuGetCommand@2
         restoreSolution: '$(solution)'
     - task: MSBuild@1
         solution: '$(solution)'
         msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
         platform: '$(buildPlatform)'
         configuration: '$(buildConfiguration)'

That's it! You've now created a build pipeline in Azure DevOps to build a .NET code repository using MSBuild as the build tool. Keep in mind that this is a general outline, and you might need to adjust some details based on your specific repository and project setup.

Did you find this article valuable?

Support Edvin Dsouza by becoming a sponsor. Any amount is appreciated!