AZ-400 Practice Question: Design and implement build and release pipelines
You are designing a YAML pipeline that builds a .NET application and publishes it as a NuGet package to Azure Artifacts. Which three tasks should you include in the build stage?
⚠ Common exam trap
Many exam-takers confuse the 'push' command as part of the build stage, but in Azure Pipelines, pushing to a feed is typically done in a separate stage or job to separate build artifacts from deployment actions.
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
✓
DotNetCoreCLI@2 with command 'build'
The DotNetCoreCLI@2 task with the 'build' command compiles the .NET application source code into intermediate language (IL) assemblies. This is a mandatory step after restoring dependencies and before packing the project into a NuGet package. Without a successful build, the subsequent pack and push operations would fail.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
DotNetCoreCLI@2 with command 'build'
Why this is correct
DotNetCoreCLI@2 with command 'build' compiles the source code and produces assembly outputs, forming the foundational step in any .NET pipeline. It validates that code compiles successfully and generates the binary artifacts that subsequent tasks such as testing or packing will consume.
- ✗
NuGetCommand@2 with command 'install'
Why it's wrong here
NuGetCommand@2 with command 'install' uses the legacy nuget.exe install behavior that downloads packages to a local packages folder and can modify the project file, which is incompatible with modern SDK-style projects that rely on PackageReference. In Azure Pipelines, 'restore' via DotNetCoreCLI@2 is the correct approach because it respects PackageReference and performs an implicit restore during build.
- ✓
DotNetCoreCLI@2 with command 'restore'
Why this is correct
DotNetCoreCLI@2 with command 'restore' resolves and downloads all NuGet dependencies declared in the project file, ensuring the required packages are available before compilation starts. It is a critical step for continuous integration, and when a packages.lock.json file is present, it guarantees deterministic, repeatable restores across builds.
- ✗
DotNetCoreCLI@2 with command 'push'
Why it's wrong here
DotNetCoreCLI@2 with command 'push' is intended for uploading a built .nupkg to a NuGet feed or package repository, an action typically performed in a release stage after the build has been validated. Including it in the build stage is often premature because the package may not yet be tested, and separate feed credentials/security boundaries are usually needed for publishing.
- ✓
DotNetCoreCLI@2 with command 'pack'
Why this is correct
DotNetCoreCLI@2 with command 'pack' creates a NuGet package (.nupkg) from the built assemblies and project metadata, such as version, authors, and dependency groups. It runs after a successful build to package the compiled output into an artifact that can be published to a feed or consumed by other projects.
Go deeper
Related to this question
Learn chapter
Introduction to DevOps and Azure DevOps
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
Azure Artifacts
Azure Artifacts is a service within Azure DevOps that allows teams to create, host, and share packages like NuGet, npm, Maven, and Python, making software dependencies easier to manage across projects.
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 →
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.