AZ-400 Practice Question: Design and implement build and release pipelines
Your pipeline builds a .NET application and runs unit tests. You notice that the pipeline takes too long because it restores NuGet packages on every run. You want to cache the NuGet packages to speed up subsequent builds. Which task should you use?
⚠ Common exam trap
Candidates often choose NuGetCommand@2 (Option A) thinking it inherently caches packages, but it only restores from remote sources each time unless combined with a separate caching task.
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@2 (CacheBeta)
The Cache@2 (CacheBeta) task is specifically designed to cache folders or files between pipeline runs, such as NuGet packages, to reduce restore time. By caching the NuGet packages folder (e.g., $(UserProfile)/.nuget/packages), subsequent builds can skip the full restore and reuse previously downloaded packages, significantly speeding up the pipeline.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
NuGetCommand@2 with the restore command
Why it's wrong here
The NuGetCommand@2 restore task does download packages via nuget restore, but it does not persist the package folder between pipeline runs; every build re-fetches dependencies unless you add a separate caching layer. It is a restore step, not a caching task, so it does not meet the requirement.
- ✗
CopyFiles@2
Why it's wrong here
CopyFiles@2 simply copies files or directories from a source to a destination within the pipeline workspace, such as staging artifacts for publishing. It has no mechanism to retain or reuse files across separate pipeline executions, so it cannot cache the NuGet packages folder.
- ✗
PowerShell@2 to manually download and cache
Why it's wrong here
While you could use PowerShell@2 to manually download and save packages to a custom cache location, this requires writing your own cache restore/save logic, and it is not the built-in pipeline caching solution. Azure DevOps provides the Cache task specifically to handle folder caching with automatic keying and restore/push, making this manual approach less optimal.
- ✓
Cache@2 (CacheBeta)
Why this is correct
The Cache@2 task (formerly CacheBeta) is Azure DevOps' built-in caching solution; it restores a folder from a cache key, and if there is a miss, it saves the folder after the job completes. For a .NET application, you can cache the ~/.nuget/packages directory (NuGet package cache) to speed up subsequent restores, so it is the correct answer.
Go deeper
Related to this question
Learn chapter
Designing a Build Pipeline
Key term
Task
A Task in Azure DevOps is a predefined, reusable step that performs a specific action during a build or release pipeline, like compiling code or running tests.
Key term
Pipeline
A pipeline is an automated series of steps that takes code from development to production, ensuring quality and speed.
About these practice questions
This AZ-400 question is part of Courseiva's 823-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
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.