Tools

Build only what changed in your .NET monorepo with dotnet-affected

Sander ten Brinke Sander ten Brinke
Tools

Pipelines in a monorepo rebuild everything on every push. Sander ten Brinke uses dotnet-affected and the MSBuild project graph to decide per application whether a change touches it, cutting agent minutes in Azure Pipelines.

Key points

  • dotnet affected walks the MSBuild project graph, so shared library changes reach every dependent application automatically.
  • Install it as a local tool in a tool manifest and CI only needs `dotnet tool restore` to pin the version.
  • Exit code 166 signals that nothing is affected, while 0 means at least one project changed.
  • `--from` sets the comparison commit and `--uncommitted none` skips a local-changes check build agents lack.
  • Pull request runs diff against `HEAD^1`, the target branch of the merge commit Azure Pipelines builds.
  • Deployment runs ask the Azure DevOps REST API for the last successful build's commit on that branch.

Real-world use

  • A monorepo holding several APIs, a web frontend and a desktop app that share common libraries
  • One pipeline per application where a single line change currently rebuilds and redeploys everything
  • Pull request pipelines that only validate code while deployments are skipped
  • A busy agent pool where redundant runs queue up PRs and slow merges

This summary was generated by the agent from the original post on Sander ten Brinke. 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