Courseiva
Design and implement build and release pipelinesmediumMultiple ChoiceObjective-mapped

AZ-400 Practice Question: Design and implement build and release pipelines

You have a YAML pipeline that builds a .NET application. You want to cache the NuGet packages to speed up subsequent builds. Which task should you use?

⚠ Common exam trap

Test-takers frequently confuse the NuGet restore task's built-in caching (which is not a parameter) with the separate Cache task, or they mistakenly believe that copying or publishing artifacts achieves caching for subsequent builds.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Cache task with a key based on the packages.lock.json hash.

The Cache task in Azure Pipelines allows you to cache NuGet packages by specifying a key derived from the hash of `packages.lock.json`. This ensures that the cache is invalidated only when the lock file changes, which accurately reflects changes in package dependencies. The cached `~/.nuget/packages` folder is then restored on subsequent runs, significantly reducing restore time.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • CopyFiles task to copy packages to a staging directory.

    Why it's wrong here

    The CopyFiles task only copies files from a source directory to a staging destination, offering no mechanism to store or restore the NuGet packages based on a cache key. It does not provide any cross-run caching; it simply stages files for later publishing.

  • NuGet restore task with 'cacheRestore' option.

    Why it's wrong here

    The NuGet restore task does not have a 'cacheRestore' option; its available parameters are for feed selection, restore mode, and related settings. Caching of restored packages must be handled separately, for example by using the Cache task with a key based on a lock file.

  • Cache task with a key based on the packages.lock.json hash.

    Why this is correct

    This is correct because the Cache task supports a key derived from the hash of packages.lock.json, which uniquely identifies the exact set of dependencies. When the key matches a previously saved cache, the packages folder is restored immediately, and after the build it is saved again, significantly improving restore time.

  • PublishBuildArtifacts task to upload packages.

    Why it's wrong here

    PublishBuildArtifacts uploads files to the artifact store for release pipelines or manual downloads, but it does not implement cache restoration or saving based on a key. It is designed for delivering build outputs, not for caching NuGet packages across pipeline runs.

About these practice questions

One of 823 original AZ-400 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This AZ-400 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-400 exam.