nerdexam
Microsoft

AZ-400 · Question #512

Drag and Drop Question You use an Azure pipeline to build a .NET app that has NuGet dependencies. You need to ensure that the pipeline caches required NuGet packages. How should you configure the pipe

The correct answer is $(Build.SourcesDirectory)/**/packages.lock.json; $(NUGET_PACKAGES). To cache NuGet packages in an Azure Pipeline, you need two key values: the 'key' (cache identifier) should be '$(Build.SourcesDirectory)/**/packages.lock.json' because the lock file captures the exact dependency tree and its hash is used to determine cache hits/misses, and the 'p

Submitted by jakub_pl· Mar 6, 2026Design and implement pipelines - Configure pipeline caching to improve build performance and manage NuGet package dependencies in Azure DevOps

Question

Drag and Drop Question You use an Azure pipeline to build a .NET app that has NuGet dependencies. You need to ensure that the pipeline caches required NuGet packages. How should you configure the pipeline? To answer, drag the appropriate values to the correct targets. Each value may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content. NOTE: Each correct selection is worth one point. Answer:

Exhibits

AZ-400 question #512 exhibit 1
AZ-400 question #512 exhibit 2

Answer Area

Drag items

$(Agent.Id)$(Build.ArtifactStagingDirectory)cache/packages$(Build.SourcesDirectory)/**/packages.lock.json$(NUGET_PACKAGES)

Correct arrangement

  • $(Build.SourcesDirectory)/**/packages.lock.json
  • $(NUGET_PACKAGES)

Explanation

To cache NuGet packages in an Azure Pipeline, you need two key values: the 'key' (cache identifier) should be '$(Build.SourcesDirectory)/**/packages.lock.json' because the lock file captures the exact dependency tree and its hash is used to determine cache hits/misses, and the 'path' should be '$(NUGET_PACKAGES)' because this environment variable points to the global NuGet packages cache directory where NuGet stores downloaded packages. Together, these ensure the cache is invalidated when dependencies change and that the correct directory is saved and restored.

Topics

#Azure Pipelines#NuGet Caching#Pipeline Optimization#CI/CD

Community Discussion

No community discussion yet for this question.

Full AZ-400 Practice