Courseiva
Design and implement build and release pipelinesmediumMultiple ChoiceObjective-mapped

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

Your team uses Azure Pipelines to build a .NET application. You notice that the build takes 15 minutes because of dependency restoration. You want to cache the NuGet packages to speed up subsequent builds. Which task should you add to your pipeline?

⚠ Common exam trap

Test-takers frequently confuse the NuGet local HTTP cache (controlled by the 'noCache' option) with the pipeline-level Cache task. The 'noCache' option only disables the HTTP cache on the local agent, but that cache persists across builds on that agent. It does not provide a distributed cache across different agents. The pipeline Cache task caches files in Azure DevOps and restores them on any agent, which is why it's the correct approach for speeding up builds across runs.

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 package lock file

The Cache task (D) is the correct choice because it allows you to cache the NuGet packages folder (typically `~/.nuget/packages`) based on a key derived from the package lock file (e.g., `packages.lock.json`). This ensures that when the lock file hasn't changed, the cached packages are restored from the pipeline cache instead of being downloaded from the NuGet feed, significantly reducing build time. The key is computed from the lock file's content hash, so any change in dependencies automatically invalidates the cache.

Answer analysis

Option-by-option breakdown

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

  • DownloadBuildArtifacts task

    Why it's wrong here

    The DownloadBuildArtifacts task is designed to fetch artifacts produced by a previous pipeline run, such as compiled binaries or reports, not to persist NuGet dependencies. It simply copies files from the artifact store into the workspace and does not interact with the NuGet package cache, so it cannot reduce restore time across builds.

  • NuGet restore task with the 'noCache' option set to false

    Why it's wrong here

    Setting the 'noCache' option to false (the default) in the NuGet restore task enables the local HTTP cache on the build agent, but this cache is per-agent and often ephemeral, lasting only for that specific job or machine. It does not provide a shared, persistent cache across separate pipeline runs, so a subsequent build on a fresh agent will still need to download packages from the feed.

  • DotNetCoreCLI task with the 'restore' command

    Why it's wrong here

    The DotNetCoreCLI task with the 'restore' command invokes dotnet restore, which downloads and resolves NuGet packages using the local cache for that single execution. While it may populate the global packages folder, it does not create a key-based cache or upload the restored packages to a durable store, so there is no cross-build reuse mechanism to avoid repeated downloads on other agents or runs.

  • Cache task with a key based on the package lock file

    Why this is correct

    The Cache task can cache NuGet packages based on the lock file hash, speeding up subsequent restores.

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.