Validate build-only container references in the pipeline - #16541
Merged
Eric Erhardt (eerhardt) merged 8 commits intoApr 30, 2026
Merged
Conversation
Eric Erhardt (eerhardt)
requested a review
from Mitch Denny (mitchdenny)
as a code owner
April 29, 2026 00:24
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16541Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16541" |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a publish/deploy-time pipeline validation to ensure “build-only” container resources are referenced via container-files annotations, preventing scenarios where build-only containers are built but never consumed in the publish/deploy graph. It also introduces an application-wide opt-out implemented as a pipeline configuration callback, and adds/updates tests and scenarios accordingly.
Changes:
- Added a new built-in pipeline step (
validate-build-only-container-references) that throws when unconsumed build-only containers are present. - Introduced
IDistributedApplicationBuilder.DisableBuildOnlyContainerValidation()which disables the validation by clearing the step’sRequiredBySteps. - Added hosting tests for the validation and opt-out behavior, and updated an Azure deploy test scenario to opt out.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.Tests/Pipelines/DistributedApplicationPipelineTests.cs | Updates expectations for the additional default pipeline step and asserts it is present. |
| tests/Aspire.Hosting.Tests/BuildOnlyContainerValidationTests.cs | Adds dedicated unit tests covering throw/non-throw behavior and the opt-out wiring. |
| tests/Aspire.Hosting.Azure.Tests/AzureDeployerTests.cs | Disables the new validation in a deploy scenario that intentionally uses build-only containers. |
| src/Aspire.Hosting/Pipelines/DistributedApplicationPipeline.cs | Adds the new validation step and implements the model scan/exception behavior. |
| src/Aspire.Hosting/DistributedApplicationBuilderExtensions.cs | Adds the public opt-out extension method that clears the validation step’s requirements. |
Eric Erhardt (eerhardt)
force-pushed
the
ThrowForUnpublishedBuildOnlyResource
branch
from
April 29, 2026 19:06
07573d4 to
86ffe19
Compare
Eric Erhardt (eerhardt)
force-pushed
the
ThrowForUnpublishedBuildOnlyResource
branch
from
April 29, 2026 22:44
86ffe19 to
07573d4
Compare
Add the publish/deploy validation step and implement the opt-out by clearing its RequiredBySteps during pipeline configuration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move DisableBuildOnlyContainerValidation to the Pipeline.
Eric Erhardt (eerhardt)
force-pushed
the
ThrowForUnpublishedBuildOnlyResource
branch
from
April 29, 2026 22:46
07573d4 to
d02eef1
Compare
Ensure manifest publishing runs the build-only container validation step and strengthen tests to cover mixed consumed and unconsumed build-only containers.
Ankit Jain (radical)
approved these changes
Apr 29, 2026
Eric Erhardt (eerhardt)
enabled auto-merge (squash)
April 29, 2026 23:28
Member
Author
|
/backport to release/13.3 |
Contributor
|
Started backporting to |
Eric Erhardt (eerhardt)
merged commit Apr 30, 2026
ab14064
into
microsoft:main
804 of 837 checks passed
Eric Erhardt (eerhardt)
deleted the
ThrowForUnpublishedBuildOnlyResource
branch
April 30, 2026 01:49
Nell Shamrell-Harrington (nellshamrell)
pushed a commit
to nellshamrell/aspire
that referenced
this pull request
May 18, 2026
…6541) * Validate build-only container references in the pipeline Add the publish/deploy validation step and implement the opt-out by clearing its RequiredBySteps during pipeline configuration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix tests * PR feedback Move DisableBuildOnlyContainerValidation to the Pipeline. * PR feedback * Fix tests * Address build-only container validation feedback Ensure manifest publishing runs the build-only container validation step and strengthen tests to cover mixed consumed and unconsumed build-only containers. * Revert publish-manifest changes. * Apply suggestion from @eerhardt --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a built-in publish/deploy validation that throws when a build-only container is not consumed through container-files annotations.
This change also:
validate-build-only-container-referencesstep'sRequiredByStepsinstead of using aPipelineOptionsflag,Validation:
dotnet test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj /p:ConfigurationSchemaExists=false --no-launch-profile -- --filter-class "*.DistributedApplicationBuilderTests" --filter-class "*.DistributedApplicationPipelineTests" --filter-class "*.BuildOnlyContainerValidationTests" --filter-class "*.ComputeEnvironmentValidationTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"dotnet test --project tests\Aspire.Hosting.Azure.Tests\Aspire.Hosting.Azure.Tests.csproj /p:ConfigurationSchemaExists=false --no-launch-profile -- --filter-method "*.DeployAsync_WithBuildOnlyContainers" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"cc David Fowler (@davidfowl)
Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: