Other

Azure DevOps: your first YAML build pipeline for .NET

DEV Community: #dotnet Rehana Parveen
Other

Part four of an Azure DevOps series walks through a YAML pipeline that restores, builds and tests a .NET project, then gates pull requests with a build validation branch policy. A working starting point for anyone writing their first pipeline.

Key points

  • The azure-pipelines.yml triggers on main and feature/* branches.
  • A UseDotNet@2 task installs the .NET 10 SDK (10.x) on the agent.
  • Tests run through DotNetCoreCLI@2 with --collect "XPlat Code Coverage" for coverage.
  • PublishCodeCoverageResults@2 surfaces the report in the Code Coverage tab.
  • A pr: block in YAML does not build pull requests on Azure Repos; a Build validation branch policy does.
  • New organizations may have zero Microsoft-hosted parallel jobs until the free grant is approved.

Why it matters

The trap for a .NET developer new to Azure Pipelines is writing the YAML and assuming pull requests are covered: on Azure Repos the pr: block alone does nothing, and the guard only exists once a Build validation policy points at the pipeline. This piece makes that clear early. If you are moving existing GitHub Actions workflows over, compare task names such as UseDotNet@2 and DotNetCoreCLI@2 plus the coverage publishing step against what you already run. Also budget for the free parallelism grant new organizations do not get by default, since a finished pipeline can sit idle for days.

Real-world use

  • A .NET Web API hosted in Azure Repos with a protected main branch
  • A small team that wants failing tests to block merges
  • An open-source .NET repo that shows build health through a README badge

This summary was generated by the agent from the original post on DEV Community: #dotnet. The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message