Pipelines: package management strategy · Topic 2 of 2

Dependency and Artifact Versioning

AZ-400 versioning: semantic versioning and CalVer, version ranges, lock files, pipeline build numbers, GitVersion, immutable artifacts and container image tags.

  • 5 min
In a nutshell
  • SemVer is MAJOR.MINOR.PATCH. Breaking change increases MAJOR. Prerelease labels sort before the release.
  • CalVer uses dates and suits scheduled products. SemVer suits libraries.
  • Lock files and exact versions make builds repeatable. Floating versions need lock files.

What it is

A version is a promise. A dependency version tells a build exactly which code it gets. An artifact version tells a deployment exactly which build it is installing. A versioning strategy is the set of rules for how numbers are chosen, how consumers declare what they accept, and how a pipeline stamps its output.

Done well, any running system can be traced to one build, and rebuilding gives the same result. Done badly, a build that passed on Monday breaks on Tuesday because a dependency moved.

Commitsource codeBuild numberunique and orderedArtifactimmutable, stampedDeploymentknows exactly what it installs

How it works

Semantic versioning (SemVer)

SemVer uses MAJOR.MINOR.PATCH, for example 2.4.1.

PartIncrease when
MAJORYou make a breaking change
MINORYou add functionality in a backward compatible way
PATCHYou make backward compatible bug fixes

A prerelease label follows a hyphen (2.5.0-beta.1) and sorts before the final release. Build metadata follows a plus sign (2.5.0+20261009) and is ignored when comparing versions.

Calendar versioning (CalVer)

CalVer uses the release date, such as 2026.10 or 2026.10.3 (year, month, then a counter). It tells users how fresh a release is rather than how risky the change is.

SchemeGood forWeakness
SemVerLibraries and APIs, where consumers need to know about breaking changesNeeds discipline to decide the increment
CalVerApplications and products released on a scheduleSays nothing about compatibility

Declaring dependency versions

StyleExampleEffect
Exact (pinned)1.4.2Always that version. Most repeatable
RangeNuGet [1.4,2.0)Any version from 1.4 up to but not including 2.0
FloatingNuGet 1.*, npm ^1.4.2 or ~1.4.2Picks up newer matching versions automatically

In npm, ^1.4.2 allows new minor and patch versions (below 2.0.0), and ~1.4.2 allows new patch versions only. Floating versions risk surprises, so combine them with lock files: package-lock.json for npm and packages.lock.json for NuGet (with locked mode restore). A lock file records the exact resolved versions, and the pipeline installs from it (npm ci) so builds are repeatable.

Automate updates with Dependabot (or similar) so pinned versions do not rot: it opens pull requests that bump versions, and your tests decide whether to accept them. Use feed views and upstream settings to control which versions teams can pick up at all.

Versioning pipeline artifacts

A pipeline stamps every run with a build number and the artifact should carry it.

name: 1.4.$(Rev:r)   # run name, for example 1.4.7

steps:
- script: echo "Building $(Build.BuildNumber)"
- script: dotnet pack -p:PackageVersion=$(Build.BuildNumber)
Variable or toolUse
name: with $(Rev:r)Sets the run name and Build.BuildNumber. $(Rev:r) is a counter that resets when the rest of the name changes
$(Build.BuildId)A unique numeric ID for the run
$(Build.SourceVersion)The commit ID the run built
GitVersionA tool that works out a SemVer number from Git history, branches and tags
Git tagsMark a release commit so the version can be recomputed

For container images, tag with something unique and immutable such as the build ID or commit SHA. The latest tag moves, so deployments should not rely on it.

Rules for artifacts

  • Immutable: once published, a version never changes. A fix is a new version.
  • Build once, deploy many: one artifact moves through test, staging and production, rather than rebuilding per environment.
  • Traceable: the version links to the commit, the run and the work items.
  • Promotable: use feed views or release stages to promote the same artifact.

A worked scenario

A team publishes a shared library as a NuGet package and an app that uses it. The library uses SemVer and is built with GitVersion so the number follows the commit history. The app pins the library with a lock file and receives upgrade pull requests from Dependabot. The app pipeline is named 2026.10.$(Rev:r), stamps that on its container image along with the commit SHA, and deploys the identical image through test and production.

What to remember for the exam

  • SemVer is MAJOR.MINOR.PATCH. Breaking change increases MAJOR. Prerelease labels sort before the release.
  • CalVer uses dates and suits scheduled products. SemVer suits libraries.
  • Lock files and exact versions make builds repeatable. Floating versions need lock files.
  • $(Build.BuildNumber), $(Build.BuildId) and $(Rev:r) stamp pipeline output. GitVersion computes SemVer from Git.
  • Artifacts are immutable. Tag images with an immutable value, not latest.
Exam tip

"A library change breaks callers" means increase the MAJOR number. "Same inputs must give the same dependencies" means lock files.

How the exam asks about this

  • "Make restores use the same versions as the last good build." A lock file or pinned versions.
  • "Number builds from Git history automatically." GitVersion.
  • "Which part changes for a breaking API change?" MAJOR.
  • "Identify exactly what image is in production." A unique tag such as the commit SHA or build ID.

Common mistakes

Overwriting a published version. Consumers with caches get different content under the same number.

Floating versions without a lock file. The build changes with no code change.

Deploying latest. It cannot tell you what is running.

Rebuilding for each environment. The artifact in production is then not the one that was tested.

Check yourself

  • In 3.2.1, which number changes for a backward compatible new feature?

    The minor number, giving 3.3.0.

  • What file records exact resolved dependency versions in npm?

    package-lock.json.

  • Which tag should a container image deployment avoid relying on?

    latest.

Topic 2 of 2 in Pipelines: package management strategy

Test yourself on Pipelines: package management strategy

The full Microsoft AZ-400 question bank has 766 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Microsoft. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.