Repository navigation
Add publish and deploy finalization boundaries - #19720
Adam Ratzman (adamint) wants to merge 14 commits into
Conversation
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 5bb7f4d6-1610-4c03-b31d-24f9a33f8499
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 19720Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 19720" |
There was a problem hiding this comment.
Pull request overview
Adds publish/deploy finalization boundaries and updates first-party pipeline work to target them.
Changes:
- Adds
PublishFinalizeandDeployFinalizepipeline steps. - Applies command-specific prerequisite gating without affecting build-only execution.
- Updates integrations, tests, and generated SDK snapshots.
Show a summary per file
| File | Description |
|---|---|
tests/Aspire.Hosting.Tests/Pipelines/DistributedApplicationPipelineTests.cs |
Tests finalizer ordering and gating. |
tests/Aspire.Hosting.Kubernetes.Tests/KubernetesHelmChartTests.cs |
Updates Helm finalizer assertion. |
tests/Aspire.Hosting.EntityFrameworkCore.Tests/EFMigrationPipelineTests.cs |
Updates migration assertions. |
tests/Aspire.Hosting.Dotnet.Tests/DotnetProjectResourceTests.cs |
Covers finalizer command roots. |
tests/Aspire.Hosting.Docker.Tests/DockerComposeTests.cs |
Tests build isolation. |
tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts |
Updates TypeScript exports. |
tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py |
Updates Python exports. |
tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java |
Updates Java exports. |
tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go |
Updates Go exports. |
src/Aspire.Hosting/Pipelines/WellKnownPipelineSteps.cs |
Defines public finalizer constants. |
src/Aspire.Hosting/Pipelines/DistributedApplicationPipeline.cs |
Adds finalizers and prerequisite normalization. |
src/Aspire.Hosting.Radius/Secrets/RadiusSecretStoreExtensions.cs |
Retargets validation gates. |
src/Aspire.Hosting.Radius/Publishing/RadiusDeploymentPipelineStep.cs |
Retargets Radius deployment. |
src/Aspire.Hosting.Radius/Publishing/RadiusBicepPublishingContext.cs |
Retargets Radius publishing. |
src/Aspire.Hosting.Kubernetes/KubernetesResource.cs |
Retargets summary work. |
src/Aspire.Hosting.Kubernetes/KubernetesHelmChartExtensions.cs |
Retargets Helm installation. |
src/Aspire.Hosting.Kubernetes/KubernetesEnvironmentResource.cs |
Retargets Kubernetes work. |
src/Aspire.Hosting.Kubernetes/Deployment/HelmDeploymentEngine.cs |
Retargets Helm deployment. |
src/Aspire.Hosting.Kubernetes/CertManagerExtensions.cs |
Retargets issuer application. |
src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs |
Retargets publish validation. |
src/Aspire.Hosting.Foundry/PromptAgent/AzurePromptAgentResource.cs |
Retargets prompt-agent deployment. |
src/Aspire.Hosting.Foundry/Project/ProjectResource.cs |
Retargets Foundry URL computation. |
src/Aspire.Hosting.Foundry/HostedAgent/AzureHostedAgentResource.cs |
Retargets hosted-agent deployment. |
src/Aspire.Hosting.EntityFrameworkCore/EFResourceBuilderExtensions.cs |
Retargets migration generation. |
src/Aspire.Hosting.Docker/DockerComposeServiceResource.cs |
Retargets service summaries. |
src/Aspire.Hosting.Docker/DockerComposeEnvironmentResource.cs |
Retargets Compose pipeline work. |
src/Aspire.Hosting.Azure/AzureEnvironmentResource.cs |
Retargets Azure publish/deploy work. |
src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebSiteResource.cs |
Retargets website summaries. |
src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentResource.cs |
Retargets App Service work. |
src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppResource.cs |
Retargets container-app summaries. |
src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppEnvironmentResource.cs |
Retargets Container Apps work. |
Review details
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 31/31 changed files
- Comments generated: 7
- Review effort level: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Fix sequential target resolution without changing callback-selected targets, and refresh affected tests and snapshots. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 5bb7f4d6-1610-4c03-b31d-24f9a33f8499
There was a problem hiding this comment.
Review details
Suppressed comments (1)
src/Aspire.Hosting/Pipelines/DistributedApplicationPipeline.cs:770
- This gates only steps directly
RequiredBythe finalizer, so transitive normal work can still start before the command prerequisite. A concrete first-party path is Radius:deploy-radius-*is required byDeployFinalizeand depends onpublish-radius-*; only the deploy step gainsdeploy-prereq, leaving the nested Bicep publish step free to run concurrently with parameter/deployment initialization. The same occurs for any intermediate aggregate. Gate the finalizer's normal-work dependency closure (excluding the prerequisite closure) rather than only directRequiredByStepsmembers.
if (step.RequiredBySteps.Contains(finalizeStep, StringComparer.Ordinal)
&& !step.DependsOnSteps.Contains(prerequisiteStep, StringComparer.Ordinal))
{
step.DependsOnSteps.Add(prerequisiteStep);
- Files reviewed: 42/42 changed files
- Comments generated: 1
- Review effort level: Balanced
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 5bb7f4d6-1610-4c03-b31d-24f9a33f8499
There was a problem hiding this comment.
Review details
Suppressed comments (1)
src/Aspire.Hosting/Pipelines/DistributedApplicationPipeline.cs:359
- The diagnostics command still feeds its target-specific resolved graph into the section labeled “full pipeline execution.” When
diagnosticsis selected, no finalizer is active, so normal deploy/publish work lacks the prerequisite edges; the updated snapshots consequently show build work beforedeploy-prereq. That differs from an actual unfiltered execution, where both finalizers are active (and is explicitly covered byExecuteAsync_WithoutSelectedStep_GatesBothFinalizerWorkloads). Build the full-analysis graph from the pre-finalization baseline and normalize it with no selected target before rendering it; keep the per-target clones for the what-if section.
DumpDependencyGraphDiagnostics(stepsToAnalyze, simulationSteps, context);
- Files reviewed: 42/42 changed files
- Comments generated: 0 new
- Review effort level: Balanced
| /// this step so post-finalize hooks can run after normal work and before final command completion. | ||
| /// </remarks> | ||
| [AspireValue("WellKnownPipelineSteps")] | ||
| public const string DeployFinalize = "deploy-finalize"; |
There was a problem hiding this comment.
The other design we considered here was to have a "RunsAfter" concept, which means when pipeline step A runs, once it is done running we run the steps that "run after" it.
Was that option considered at all? It would be the more flexible option, so you could run after any step, and then if someone did aspire do stepA, your step would run.
This is a concept MSBuild has, but we cut it out of the initial pipeline design.
I wonder how hard it would be to add it.
I think this is my only high level concern with this approach. And it doesn't mean we can't have both. We could do the "finalize" option today, and still add the "RunsAfter" concept in the future.
There was a problem hiding this comment.
I think RunsAfter is a separate feature because it changes what aspire do stepA selects. We should define transitivity, consumer ordering, and failure semantics first. The finalizers solve the narrower completion-boundary problem without changing targeted execution, and we can add RunsAfter later.
Preserve configuration callback mutations while keeping resolution-local graph normalization, gate nested finalizer work behind command prerequisites, and render full diagnostics with unfiltered finalization boundaries. Co-authored-by: Copilot <[email protected]>
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 7c01c030-226e-41c5-81ca-a6483a1856df
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Azure Sandbox deployment still bypasses the finalizer, allowing post-finalize hooks to run before sandbox deployment completes.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/Aspire.Hosting/Pipelines/DistributedApplicationPipeline.cs — The Azure Sandbox deploy step still uses RequiredBySteps = [WellKnownPipelineSteps.Deploy] in… |
| Description = "Aggregation step for all deploy operations. All deploy steps should be required by this step.", | ||
| Description = "Final aggregation step for deploy command completion. Post-finalize hooks should depend on deploy-finalize and be required by this step.", | ||
| Action = _ => Task.CompletedTask, | ||
| DependsOnSteps = [WellKnownPipelineSteps.DeployFinalize], |
|
Good call, this sandbox step is still required by |
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 7c01c030-226e-41c5-81ca-a6483a1856df
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
RPC list-step requests can normalize against a different target and incorrectly introduce deploy prerequisites into build results.
Review tier: Balanced
Findings: 1
Pre-existing issues (1)
| Severity | Finding |
|---|---|
src/Aspire.Hosting/Pipelines/DistributedApplicationPipeline.cs — The Azure Sandbox deploy step still uses RequiredBySteps = [WellKnownPipelineSteps.Deploy] in… View comment |
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/Aspire.Hosting/Pipelines/DistributedApplicationPipeline.cs:640
ResolveStepsAsyncnow chooses command-specific gates only fromPipelineOptions.Step, butAppHostRpcTarget.GetPipelineStepsAsyncresolves through this method and then filters withrequest.Step(AppHostRpcTarget.cs:305-313). If an inspection host starts without--stepand the RPC requestsbuild, both finalizers are activated before filtering, so shared build work incorrectly acquiresdeploy-prereq. Thread the RPC target into the target-aware resolution path so list-step filtering uses the same target as normalization.
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |

Description
Pipeline contributors previously had no explicit barrier between ordinary publish/deploy work and hooks that must run after that work. This adds
publish-finalizeanddeploy-finalizewhile keepingpublishanddeployas the final command-completion aggregates:Normal first-party work now targets the matching finalizer across Docker Compose, Kubernetes, Azure, Foundry, Radius, JavaScript, and Entity Framework Core. The scheduler adds prerequisite gates only when the selected command reaches that finalizer, including nested publish work during deploy, so shared build steps stay isolated when
buildis selected.Direct third-party attachments to
publishordeployremain supported and may run in parallel with the finalizer branch. The intentional first-party direct references that remain are:publishanddeployaggregate definitions;Aspire.dev documentation: microsoft/aspire.dev#1587.
User-facing usage
Ordinary publish work should complete before
PublishFinalize:A hook that runs after ordinary publish work but before command completion should use both edges:
The same pattern applies to
DeployFinalizeandDeploy.Real CLI scenarios
Installed the dogfood artifact and confirmed it matches this PR's head commit:
The temporary C# AppHost registered one normal step before each finalizer and one post-finalize hook before each final aggregate:
The same setup used
DeployFinalizeandDeployfor deploy.aspire publish --list-stepsresolved the expected structure:The real publish command executed in that order and did not complete the aggregate until the post-finalize hook completed:
aspire deploy --list-stepsresolved the corresponding deploy structure:The real deploy command produced the same runtime ordering:
Validation
./restore.sh— passeddotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-class "*.DistributedApplicationPipelineTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"— 94 passedAspire.Hosting,Aspire.Hosting.Tests, Docker, Kubernetes, Azure App Containers, and Azure App Service — passed with zero warnings/errorsgit diff --check— passed*/api/*.csbaseline changedaspire publishscenario — 11/11 steps passedaspire deployscenario — 11/11 steps passedFixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?