Building a .NET Code Repository in Azure DevOps Using MS Build: Step-by-Step Guide
Step 1: Set up Azure DevOps Project
Go to dev.azure.com and sign in with your Azure DevOps account.
Click on "Create project" to create a new project or use an existing one.
Step 2: Create a New Git Repository
In your Azure DevOps project, click on "Repos" in the left sidebar.
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
In your Azure DevOps project, click on "Pipelines" in the left sidebar.
Click on "Create pipeline" to create a new pipeline.
Select the repository you imported in Step 2 and choose the branch you want to build.
Step 4: Configure the Build Pipeline
Azure DevOps will analyze your repository and suggest templates. Choose "Starter pipeline" or "Empty job" if you prefer to configure everything manually.
You'll be directed to the pipeline editor.
Step 5: Define Build Steps
Update VM Image: Replace the existing
pool: vmImage: 'vs2017-win2016'
section in your YAML withpool: vmImage: 'windows-latest'
. By using thewindows-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.Switch to MSBuild: Replace the current
VSBuild
task with theMSBuild
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.pool: vmImage: 'windows-latest' variables: solution: './ClientLibrary/Samples/ClientSamples.sln' buildPlatform: 'Any CPU' buildConfiguration: 'Release' steps: - task: NuGetToolInstaller@0 - task: NuGetCommand@2 inputs: restoreSolution: '$(solution)' - task: MSBuild@1 inputs: 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.