Repository navigation
Warn for Go and fail for Python publish when an existing Dockerfile ignores the entrypoint - #21186
Conversation
When the app directory already contains a Dockerfile, AddGoApp skips Dockerfile generation, so a non-default packagePath was silently dropped from the published image. Throw while writing the manifest and from a pipeline validation step, mirroring the JavaScript run script guard, unless the user sets an explicit container entrypoint with PublishAsDockerFile(...). Build flags and the race detector are not entrypoint selection and are left alone. Part of #19070. Co-authored-by: Copilot App <[email protected]> Copilot-Session: c8717a87-0ee5-4296-a6fd-ea6e2d91a57e
When the app directory already contains a Dockerfile, AddPython* skips Dockerfile generation, so an entrypoint changed with WithEntrypoint(...) was silently dropped from the published image. Throw while writing the manifest and from a pipeline validation step, mirroring the JavaScript run script guard, unless the user sets an explicit container entrypoint with PublishAsDockerFile(...). Python has no default entrypoint and apps that ship their own Dockerfile are expected to run it, so only an entrypoint that differs from the one passed to AddPython* is treated as an explicit request. Part of #19070. Co-authored-by: Copilot App <[email protected]> Copilot-Session: c8717a87-0ee5-4296-a6fd-ea6e2d91a57e
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21186Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21186" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Validation blocks excluded resources, and the added pipeline annotations break subsequent Dockerfile customization.
3 open issues
What changed in this PR
Adds publish-time guards for Go and Python apps whose existing Dockerfiles may ignore configured entrypoints, following JavaScript’s existing behavior.
Changes:
- Adds manifest and Build/Publish pipeline validation.
- Preserves supported defaults and explicit container entrypoint overrides.
- Adds regression tests and a Python Dockerfile snapshot.
| File | Description |
|---|---|
| src/Aspire.Hosting.Go/GoHostingExtensions.cs | Validates non-default Go package paths. |
| src/Aspire.Hosting.Python/PythonAppResourceBuilderExtensions.cs | Validates changed Python entrypoints. |
| tests/Aspire.Hosting.Go.Tests/AddGoAppTests.cs | Tests Go validation and bypass cases. |
| tests/Aspire.Hosting.Python.Tests/AddPythonAppTests.cs | Tests Python validation and Dockerfile generation. |
| tests/Aspire.Hosting.Python.Tests/Snapshots/AddPythonAppTests.PublishWithoutDockerfileGeneratesDockerfileWhenEntrypointIsChanged.verified.txt | Records the generated module entrypoint. |
Review effort: 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. |
James Newton-King (JamesNK)
left a comment
There was a problem hiding this comment.
Found 1 additional correctness issue: the new Go/Python entrypoint validation is bypassed by the Azure deployment dependency graph. Existing review comments were not duplicated.
Validation: 7 focused Go regression cases and 10 focused Python regression cases passed. A temporary Azure Container Apps pipeline-graph regression test reproduced the missing validation dependency; it was removed afterward. The broader Go test-class run had 43 passes and 11 snapshot failures caused by CRLF baseline line endings in the local checkout.
EnsureBuildAndPushPipelineAnnotations registered its steps with ResourceAnnotationMutationBehavior.Replace, which resolves to Annotations.OfType<PipelineStepAnnotation>().SingleOrDefault(). A container that also carries another PipelineStepAnnotation, such as the Go and Python Dockerfile validators, made the next WithDockerfile call throw "Sequence contains more than one element", and a single annotation added by a caller was silently dropped. Register the build and push steps with an internal annotation type so Replace only ever replaces that registration. Consumers still collect the steps through OfType<PipelineStepAnnotation>(). Two registrants relied on the old replace-everything behavior: - EF migration bundle containers re-registered the migration step that AddEFMigrationsCore already adds, so it would now be emitted twice. - Dotnet program publishing adds SDK build steps that the container conversion in PublishAsDockerFile used to wipe, so it would now emit a second build step. Skip it unless the resource still supports it. Co-authored-by: Copilot App <[email protected]> Copilot-Session: c8717a87-0ee5-4296-a6fd-ea6e2d91a57e
The validation step added for an existing Dockerfile ran for every Go and Python app, including resources excluded from the manifest with ExcludeFromManifest(). Those apps are never published, yet a conflicting package path or entrypoint failed the Build and Publish steps and blocked unrelated resources. Return no step for them, like the container build step factory does. The manifest path needs no change: an excluded resource is written with a null callback, so the validating callback never runs for it. Also cover the case from review where PublishAsDockerFile is followed by WithDockerfile in publish mode: it no longer throws and the validation still fires, and an explicit WithEntrypoint still bypasses it. Co-authored-by: Copilot App <[email protected]> Copilot-Session: c8717a87-0ee5-4296-a6fd-ea6e2d91a57e
The validation step was only required by the aggregate Build and Publish steps. Deploy environments such as Azure Container Apps, App Service, Docker Compose and Kubernetes select each resource's BuildCompute step directly and do not depend on those aggregates, so a conflicting existing Dockerfile was still built and deployed without any error. Make the resource's own image build step depend on the validation step. This does not hardcode the build step name, and it is a no-op for resources excluded from publish, which have neither step. The new tests assert on the dependency graph instead of running the validation step directly: the build step closure contains the validation step for Go and Python, and the Azure Container Apps Deploy closure contains it for a Python app. There is no Go equivalent of the latter because Aspire.Hosting.Tests does not reference Aspire.Hosting.Go. Co-authored-by: Copilot App <[email protected]> Copilot-Session: c8717a87-0ee5-4296-a6fd-ea6e2d91a57e
This comment has been minimized.
This comment has been minimized.
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Add the validation steps with Pipeline.AddStep instead of as a PipelineStepAnnotation on the container. WithDockerfile replaces the container's step annotation, so an annotation step would be dropped, or would make the registration throw, when PublishAsDockerFile configures the Dockerfile again. A pipeline step is not affected, so the shared WithDockerfile, EF migration and .NET program publishing changes are no longer needed and are reverted. The step is always registered and does nothing for a resource that is excluded from the manifest. The tests use the application's pipeline, because only that pipeline contains steps added with Pipeline.AddStep. Co-authored-by: Copilot App <[email protected]> Copilot-Session: c8717a87-0ee5-4296-a6fd-ea6e2d91a57e
This comment has been minimized.
This comment has been minimized.
Sébastien Ros (sebastienros)
left a comment
There was a problem hiding this comment.
Thanks for this. The validation mechanics look solid: the guard only inspects annotations, so Dockerfile contents can't cause false positives, and the step ordering, exclusion handling and WithDockerfile reconfiguration are well covered by the tests. I'm leaving this as a comment rather than an approval because of one behavior question.
To resolve before approval: the Go guard fails publish whenever packagePath is not ".", even when the app's own Dockerfile already builds and runs that package correctly. The inline comment has the details.
Other points (non-blocking):
AddGoAppaddsGoPackagePathAnnotationwhenpackagePath != "."(line 287, outside this diff), so"./"or"./.", which mean the same as the default, now fail publish when an existing Dockerfile is present. Normalizing the value before that check would avoid this.- The JavaScript guard (
JavaScriptHostingExtensions.cs) still registers its validation as aPipelineStepAnnotationon the container, the pattern this PR moved away from because a laterPublishAsDockerFile(c => c.WithDockerfile(...))drops it or throws. That could be a follow-up issue. - Optional: the Go and Python registration blocks (manifest callback,
Pipeline.AddStep, BuildCompute dependency) are nearly identical. A small shared internal helper would keep the languages from drifting.
Go: emit a publish-time warning instead of throwing when an existing Dockerfile is published with a non-default package path, so apps whose Dockerfile already builds that package keep publishing. './' and './.' are treated as the default package path. Python: compare Script entrypoints after resolving them against the app directory so restating 'main.py' as './main.py' is not reported as a conflict. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 74f4d906-4ced-495b-b816-c2983ca25399
This comment has been minimized.
This comment has been minimized.
Resolve the AddGoAppTests.cs conflict by keeping both the new Go certificate trust tests from main and this PR's Dockerfile validation tests and helpers. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 74f4d906-4ced-495b-b816-c2983ca25399
Tests selector11 / 100 PR test projects · 2 PR jobs, from 7 changed files. Selected PR test projects (11 / 100)
Selected PR jobs (2)
How these were chosen — grouped by what changed
🧪 🔧 📦 affected project 🔧 🧪 🧪 🧪 🧪 Job reasons
Selection computed for commit |
|
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. |
|
Pull request created: #1979
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#1979 targeting Documents the new publish behavior with an existing Dockerfile: Go warns, Python fails when the entrypoint is changed. Updated Note This draft PR needs human review before merging. |
> [!IMPORTANT] > **Merge last.** This PR depends on the other open Go AppHost PRs and must land after them. > > - **Must land first**, because each adds references to the flag that this PR has to delete: #21189 (E2E helper and call sites), #21195 (`SdkExportCommandTests`) and #21196 (`GoAppHostToolingCheck` and its tests). > - **Must land first**, because it edits the same hunk of `DefaultLanguageDiscovery.cs` and this PR rebases onto it: #21191. > - **Should land first**, because removing the flag turns Go on for everyone and these fixes should ship before it: #21186, #21187, #21188, #21193, #21194, #21197 and #21199. ## Description Removes the `experimentalPolyglotGo` feature flag so Go AppHosts are available by default, the same way TypeScript AppHosts are. With no flag, **Empty (Go AppHost)** and **Starter App (Go API + Redis, Go AppHost)** are offered by interactive and non-interactive `aspire new`, and Go is offered by `aspire init` language selection and `--language go`. **This is the GA switch for the Go AppHost epic (#21115) and must merge last**, after the other children have landed: #21108 (E2E, publish, deploy), #21110 (support policy, API review, packaging), #21112 (docs and samples) and #21114 (VS Code debugging). It was opened as a draft so CI exercises the 52 Go fixtures without the flag. It is ready for review now, but not for merging. What changed: - **CLI:** `KnownFeatures` drops the Go flag and `DefaultLanguageDiscovery` no longer marks Go experimental. `LanguageInfo.IsExperimental` is kept because Python, Java and Rust still use it. - **Leftover key:** a stale `experimentalPolyglotGo` in a user's configuration is ignored with no warning, matching what happened to the TypeScript flag when it was removed. `Features` only reads named keys, and the extension schemas set `additionalProperties: false`, so VS Code flags the stale key. - **Extension schemas:** `aspire-config`, `aspire-global-settings` and `aspire-settings` are regenerated with `extension/scripts/generate-schema.js`. Only the 16-line Go block is removed from each. - **Fixtures and CI:** 52 `tests/PolyglotAppHosts/*/Go/aspire.config.json` files and `.github/workflows/polyglot-validation/Dockerfile.golang` no longer set the key. - **Java E2E picker offsets:** Go is always listed now, so with only the Java flag set the `aspire init` language picker is C#, TypeScript, Go, Java, and Java needs 3 Down presses instead of 2. The first CI run on this PR timed out waiting for `> Java` in `JavaPolyglotTests`, `JavaCodegenValidationTests` and `JavaPolyglotApphostDirectoryTests`; each now presses Down once more, with a comment stating the picker order. The order comes from `DefaultLanguageDiscovery`, `LanguageService` and `CliTemplateFactory`. TypeScript flows are unaffected because TypeScript sorts before Go. - **Tests:** `DefaultLanguageDiscoveryTests`, `NewCommandTests`, `ConfigCommandTests`, `NewCommandTemplateConfigPersistenceTests` and `InitCommandTests` now expect Go without the flag, with 6 new tests. One of them, `GetAvailableLanguagesAsync_ListsLanguagesInPickerOrder`, pins the picker order so a future ungated language fails a unit test before it breaks a Docker E2E run. - **Docs:** `docs/specs/polyglot-apphost.md`, the Go code generation README and `playground/GoAppHost/apphost.go` no longer mention the flag. Fixes #21106 ## Validation | Command | Result | | --- | --- | | `.\restore.cmd` | passed | | `dotnet build tests\Aspire.Cli.EndToEnd.Tests\Aspire.Cli.EndToEnd.Tests.csproj -m:2 --no-restore` | 0 warnings, 0 errors | | `dotnet test --project tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class "*.DefaultLanguageDiscoveryTests" --filter-class "*.NewCommandTests" --filter-class "*.ConfigCommandTests" --filter-class "*.NewCommandTemplateConfigPersistenceTests" --filter-class "*.InitCommandTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"` | 312 passed, 0 failed (run before the picker-order test was added) | | `dotnet test --project tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class "*.DefaultLanguageDiscoveryTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"` | 39 passed, 0 failed (38 existing plus the picker-order test) | | `node extension\scripts\generate-schema.js` | only the Go block was removed from each schema | | repository-wide search for `experimentalPolyglotGo` and its variants | 0 hits | | JSON parse of the 53 fixtures and 3 schemas | all parse, none contain the flag | Run in PR CI instead of locally, all passing on `0e65752d44`: the three Java E2E tests (`JavaPolyglotTests`, `JavaCodegenValidationTests` and `JavaPolyglotApphostDirectoryTests`; they need Docker, so CI was the first execution of the extra Down press), `Infrastructure.Tests` and the VS Code extension unit and E2E jobs. Not run: the VS Code new-project flow in an extension host (`extension/src/commands/new.ts` just runs `aspire new`). ### Before merging - [ ] Search again for `experimentalPolyglotGo`, `KnownFeatures.ExperimentalPolyglotGo`, `EnableExperimentalGoSupportAsync`, `features__experimentalPolyglotGo` and `experimentalPolyglot:go`, because open Go branches add flag setup of their own and this PR must merge after all of them. Today that covers #21189 (the `EnableExperimentalGoSupportAsync` helper and its call sites in every Go scenario), #21195 (`SdkExportCommandTests` sets `KnownFeatures.ExperimentalPolyglotGo`) and #21196 (`GoAppHostToolingCheckTests` builds its language discovery with the flag, including a `goEnabled: false` case that stops being meaningful, and `GoAppHostToolingCheck` has a comment that describes the flag). Each of them stops compiling or goes stale once the flag is removed, so delete or rewrite them here. - [ ] Rebase onto #21191, which adds `DefaultHostingPackages = ["Aspire.Hosting.Go"]` to Go's `LanguageInfo` in the same hunk of `DefaultLanguageDiscovery.cs` (#21045). Keep that initializer and drop `IsExperimental: true`. - [ ] Drop the Go experimental notes in the aspire.dev API reference and docs at the same time. ## Checklist - Is this feature complete? - [ ] Yes. Ready to ship. - [x] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [ ] Yes - If yes, did you have an API Review for it? - [ ] Yes - [ ] No - Did you add `<remarks />` and `<code />` elements on your triple slash comments? - [ ] Yes - [ ] No - [x] No - Does the change make any security assumptions or guarantees? - [ ] Yes - If yes, have you done a threat model and had a security review? - [ ] Yes - [ ] No - [x] No --------- Co-authored-by: David Pine <[email protected]> Co-authored-by: Copilot App <[email protected]> Copilot-Session: c8717a87-0ee5-4296-a6fd-ea6e2d91a57e
…ipeline registration (#21461) ## Description Part of #21205. Aligns the JavaScript existing-Dockerfile run-script validator (`validate-javascript-dockerfile-run-script-{name}`) with the Go and Python validators fixed in #21186. ### Bugs on `main`, each reproduced by a new test 1. **Excluded resources still fail publish.** A JavaScript app with an existing Dockerfile and an explicit run script that is marked `ExcludeFromManifest()` still runs the validator and throws `JavaScript app resource 'js' is configured to run script 'migrate', but publish is using the existing Dockerfile ...`. The resource isn't published at all, so this failure is spurious. 2. **`PublishAsDockerFile(c => c.WithDockerfile(...))` crashes in publish mode.** The validator was a second `PipelineStepAnnotation` on the container. `WithDockerfile` calls `EnsureBuildAndPushPipelineAnnotations`, which adds its annotation with `ResourceAnnotationMutationBehavior.Replace` and then fails with `InvalidOperationException: Sequence contains more than one element`. 3. **Deploy graphs skip the validator.** It was only `RequiredBySteps = [Build, Publish]`. Azure Container Apps and App Service select a resource's `BuildCompute` steps directly, so `build-{name}` never depended on the validator. ### Fix This is the same shape #21186 merged for Go and Python: - Register the step through `builder.Pipeline.AddStep`, so it's no longer a container annotation that `WithDockerfile` can replace. - Skip validation when `containerBuilder.Resource.IsExcludedFromPublish()`. - Make the container's `BuildCompute` steps depend on the validation step through `WithPipelineConfiguration`. The existing test `PublishPipelineWithExistingDockerfileThrowsFromValidationStepWhenRunScriptNameIsExplicit` built a bare `new DistributedApplicationPipeline()`, which doesn't contain steps added through `builder.Pipeline`. It now resolves the app's `IDistributedApplicationPipeline`, as the Go and Python tests in #21186 do. Its assertions are unchanged. Not in this PR (remaining #21205 items): the Next.js standalone check's `BuildCompute` dependency and a shared helper across Go, Python and JavaScript. ### Before/after (local) | Test | Before (`main` source) | After | |---|---|---| | `PublishPipelineValidationStepIsNoOpForResourceExcludedFromManifest` | ❌ `DistributedApplicationException: JavaScript app resource 'js' is configured to run script 'migrate' ...` | ✅ | | `PublishPipelineValidationStepSurvivesLaterWithDockerfile` | ❌ `InvalidOperationException: Sequence contains more than one element` (from `WithDockerfile`) | ✅ | | `PublishPipelineRunsValidationStepBeforeImageBuildStep` | ❌ `Assert.Contains() Failure: Filter not matched` (validator not in the `build-js` closure) | ✅ | - The four `*PublishPipeline*` tests pass in 20/20 repeated runs. - Full `Aspire.Hosting.JavaScript.Tests`: 408/427 pass locally. The 19 failures are environmental and unrelated: - Bun and Deno functional tests fail in 0ms because those tools aren't installed. - Verify snapshot tests fail because the sandbox HOME is `/root`, which the scrubber rewrites inside `/root/.cache`. With a different HOME, all 101 snapshot tests pass. ## Checklist - Is this feature complete? - [ ] Yes. Ready to ship. - [x] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [ ] Yes - If yes, did you have an API Review for it? - [ ] Yes - [ ] No - Did you add `<remarks />` and `<code />` elements on your triple slash comments? - [ ] Yes - [ ] No - [x] No - Does the change make any security assumptions or guarantees? - [ ] Yes - If yes, have you done a threat model and had a security review? - [ ] Yes - [ ] No - [x] No **🤖 Posted by AspireAgent (AI Agent)** --------- Co-authored-by: davidfowl <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: David Pine <[email protected]> Co-authored-by: IEvangelist <[email protected]>
…ipeline registration (#21461) ## Description Part of #21205. Aligns the JavaScript existing-Dockerfile run-script validator (`validate-javascript-dockerfile-run-script-{name}`) with the Go and Python validators fixed in #21186. ### Bugs on `main`, each reproduced by a new test 1. **Excluded resources still fail publish.** A JavaScript app with an existing Dockerfile and an explicit run script that is marked `ExcludeFromManifest()` still runs the validator and throws `JavaScript app resource 'js' is configured to run script 'migrate', but publish is using the existing Dockerfile ...`. The resource isn't published at all, so this failure is spurious. 2. **`PublishAsDockerFile(c => c.WithDockerfile(...))` crashes in publish mode.** The validator was a second `PipelineStepAnnotation` on the container. `WithDockerfile` calls `EnsureBuildAndPushPipelineAnnotations`, which adds its annotation with `ResourceAnnotationMutationBehavior.Replace` and then fails with `InvalidOperationException: Sequence contains more than one element`. 3. **Deploy graphs skip the validator.** It was only `RequiredBySteps = [Build, Publish]`. Azure Container Apps and App Service select a resource's `BuildCompute` steps directly, so `build-{name}` never depended on the validator. ### Fix This is the same shape #21186 merged for Go and Python: - Register the step through `builder.Pipeline.AddStep`, so it's no longer a container annotation that `WithDockerfile` can replace. - Skip validation when `containerBuilder.Resource.IsExcludedFromPublish()`. - Make the container's `BuildCompute` steps depend on the validation step through `WithPipelineConfiguration`. The existing test `PublishPipelineWithExistingDockerfileThrowsFromValidationStepWhenRunScriptNameIsExplicit` built a bare `new DistributedApplicationPipeline()`, which doesn't contain steps added through `builder.Pipeline`. It now resolves the app's `IDistributedApplicationPipeline`, as the Go and Python tests in #21186 do. Its assertions are unchanged. Not in this PR (remaining #21205 items): the Next.js standalone check's `BuildCompute` dependency and a shared helper across Go, Python and JavaScript. ### Before/after (local) | Test | Before (`main` source) | After | |---|---|---| | `PublishPipelineValidationStepIsNoOpForResourceExcludedFromManifest` | ❌ `DistributedApplicationException: JavaScript app resource 'js' is configured to run script 'migrate' ...` | ✅ | | `PublishPipelineValidationStepSurvivesLaterWithDockerfile` | ❌ `InvalidOperationException: Sequence contains more than one element` (from `WithDockerfile`) | ✅ | | `PublishPipelineRunsValidationStepBeforeImageBuildStep` | ❌ `Assert.Contains() Failure: Filter not matched` (validator not in the `build-js` closure) | ✅ | - The four `*PublishPipeline*` tests pass in 20/20 repeated runs. - Full `Aspire.Hosting.JavaScript.Tests`: 408/427 pass locally. The 19 failures are environmental and unrelated: - Bun and Deno functional tests fail in 0ms because those tools aren't installed. - Verify snapshot tests fail because the sandbox HOME is `/root`, which the scrubber rewrites inside `/root/.cache`. With a different HOME, all 101 snapshot tests pass. ## Checklist - Is this feature complete? - [ ] Yes. Ready to ship. - [x] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [ ] Yes - If yes, did you have an API Review for it? - [ ] Yes - [ ] No - Did you add `<remarks />` and `<code />` elements on your triple slash comments? - [ ] Yes - [ ] No - [x] No - Does the change make any security assumptions or guarantees? - [ ] Yes - If yes, have you done a threat model and had a security review? - [ ] Yes - [ ] No - [x] No **🤖 Posted by AspireAgent (AI Agent)** --------- Co-authored-by: davidfowl <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: David Pine <[email protected]> Co-authored-by: IEvangelist <[email protected]> (cherry picked from commit 059be63)
…ipeline registration (#21461) ## Description Part of #21205. Aligns the JavaScript existing-Dockerfile run-script validator (`validate-javascript-dockerfile-run-script-{name}`) with the Go and Python validators fixed in #21186. ### Bugs on `main`, each reproduced by a new test 1. **Excluded resources still fail publish.** A JavaScript app with an existing Dockerfile and an explicit run script that is marked `ExcludeFromManifest()` still runs the validator and throws `JavaScript app resource 'js' is configured to run script 'migrate', but publish is using the existing Dockerfile ...`. The resource isn't published at all, so this failure is spurious. 2. **`PublishAsDockerFile(c => c.WithDockerfile(...))` crashes in publish mode.** The validator was a second `PipelineStepAnnotation` on the container. `WithDockerfile` calls `EnsureBuildAndPushPipelineAnnotations`, which adds its annotation with `ResourceAnnotationMutationBehavior.Replace` and then fails with `InvalidOperationException: Sequence contains more than one element`. 3. **Deploy graphs skip the validator.** It was only `RequiredBySteps = [Build, Publish]`. Azure Container Apps and App Service select a resource's `BuildCompute` steps directly, so `build-{name}` never depended on the validator. ### Fix This is the same shape #21186 merged for Go and Python: - Register the step through `builder.Pipeline.AddStep`, so it's no longer a container annotation that `WithDockerfile` can replace. - Skip validation when `containerBuilder.Resource.IsExcludedFromPublish()`. - Make the container's `BuildCompute` steps depend on the validation step through `WithPipelineConfiguration`. The existing test `PublishPipelineWithExistingDockerfileThrowsFromValidationStepWhenRunScriptNameIsExplicit` built a bare `new DistributedApplicationPipeline()`, which doesn't contain steps added through `builder.Pipeline`. It now resolves the app's `IDistributedApplicationPipeline`, as the Go and Python tests in #21186 do. Its assertions are unchanged. Not in this PR (remaining #21205 items): the Next.js standalone check's `BuildCompute` dependency and a shared helper across Go, Python and JavaScript. ### Before/after (local) | Test | Before (`main` source) | After | |---|---|---| | `PublishPipelineValidationStepIsNoOpForResourceExcludedFromManifest` | ❌ `DistributedApplicationException: JavaScript app resource 'js' is configured to run script 'migrate' ...` | ✅ | | `PublishPipelineValidationStepSurvivesLaterWithDockerfile` | ❌ `InvalidOperationException: Sequence contains more than one element` (from `WithDockerfile`) | ✅ | | `PublishPipelineRunsValidationStepBeforeImageBuildStep` | ❌ `Assert.Contains() Failure: Filter not matched` (validator not in the `build-js` closure) | ✅ | - The four `*PublishPipeline*` tests pass in 20/20 repeated runs. - Full `Aspire.Hosting.JavaScript.Tests`: 408/427 pass locally. The 19 failures are environmental and unrelated: - Bun and Deno functional tests fail in 0ms because those tools aren't installed. - Verify snapshot tests fail because the sandbox HOME is `/root`, which the scrubber rewrites inside `/root/.cache`. With a different HOME, all 101 snapshot tests pass. ## Checklist - Is this feature complete? - [ ] Yes. Ready to ship. - [x] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [ ] Yes - If yes, did you have an API Review for it? - [ ] Yes - [ ] No - Did you add `<remarks />` and `<code />` elements on your triple slash comments? - [ ] Yes - [ ] No - [x] No - Does the change make any security assumptions or guarantees? - [ ] Yes - If yes, have you done a threat model and had a security review? - [ ] Yes - [ ] No - [x] No **🤖 Posted by AspireAgent (AI Agent)** --------- Co-authored-by: davidfowl <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: David Pine <[email protected]> Co-authored-by: IEvangelist <[email protected]> (cherry picked from commit 059be63)
…thon (#1979) Documents changes from microsoft/aspire#21186 Author: ``@IEvangelist-reviewed`` source PR author per source PR metadata (see source PR). Targeting `release/17.0` based on the source PR milestone `17.0` (`exact_match`). ## Why Publishing a Go or Python app with its own `Dockerfile` previously ignored the resource's entrypoint silently. Go now logs a warning when `packagePath` isn't the app directory; Python now fails when `WithEntrypoint(...)` changes the entrypoint. Docs didn't describe this. ## Changes (updated pages) - `src/frontend/src/content/docs/integrations/frameworks/python.mdx`: new "Use an existing Dockerfile" section. - `src/frontend/src/content/docs/integrations/frameworks/go/go-host.mdx`: new "Use an existing Dockerfile" section under Publish Go apps. Triggered signal: `pr_body_has_cli_flag_mention` (`--publisher manifest` note). > Generated by [PR Documentation Check](https://github.com/microsoft/aspire/actions/runs/40914589241) for #21186 · copilot · auto · 27.5 AIC · ⌖ 1.15 AIC · ⊞ 7.1K · [◷](https://github.com/search?q=repo%3Amicrosoft%2Faspire.dev+%22gh-aw-workflow-id%3A+pr-docs-check%22&type=pullrequests) <!-- gh-aw-agentic-workflow: PR Documentation Check, engine: copilot, model: auto, id: 40914589241, workflow_id: pr-docs-check, run: https://github.com/microsoft/aspire/actions/runs/40914589241 --> <!-- gh-aw-workflow-id: pr-docs-check --> <!-- gh-aw-workflow-call-id: microsoft/aspire/pr-docs-check --> Co-authored-by: aspire-repo-bot[bot] <268009190+aspire-repo-bot[bot]@users.noreply.github.com>

Description
Publishing a Go or Python app that has its own
Dockerfilein the app directory silently ignored the entrypoint the resource was given.AddGoAppskips Dockerfile generation when aDockerfileexists, so a non-defaultpackagePathnever reached the image.AddPython*does the same for an entrypoint changed withWithEntrypoint(...). JavaScript already fails loudly in the same situation. Python now fails the same way, and Go warns.With an existing app-directory
Dockerfile, publish now reports when the resource carries an entrypoint the Dockerfile cannot honor. Both languages do it from avalidate-{go,python}-...-{name}pipeline step that is required by Build and Publish, and the resource's own image build (theBuildComputestep that Azure Container Apps, App Service, Docker Compose and Kubernetes deployments select directly) waits for it. The step does nothing for a resource excluded from the manifest, because that resource is never published. The message names the resource, the requested package or entrypoint and the Dockerfile path. It is bypassed byPublishAsDockerFile(c => c.WithEntrypoint(...)), which sets the container entrypoint explicitly.packagePathresolves to something other than the app directory.AddGoApprecords aGoPackagePathAnnotationfor any path other than the literal".", so the guard also treats"./"and"./."as the app directory. It does not throw, because a custom Dockerfile can already build and run the requested package and failing would break apps that publish correctly today. Build tags, ldflags, gcflags and the race detector are build configuration, not entrypoint selection, so they do not warn (a test documents this). The warning comes from the pipeline step, so a manifest-only publish (--publisher manifest, as used byazd) does not show it.DistributedApplicationExceptionfrom the manifest callback and from the pipeline step, the same two places as the JavaScript guard. It fires only when the effective entrypoint differs from the one passed toAddPython*, meaning a laterWithEntrypoint(...)re-pointed it. Python has no default entrypoint and apps that ship their own Dockerfile are expected to run it, so a broad throw would break them. Re-stating the same entrypoint is not a conflict, and a Script entrypoint is compared after it is resolved against the app directory, so./main.pyis the same file asmain.py.WithEntrypoint(EntrypointType...)and no non-default GopackagePath. The Go starter usesAddGoApp("api", "./api"), which is the default package path.PublishAsDockerFile(c => c.WithDockerfile(path))callsWithDockerfileon a container that already has the validation, andWithDockerfilereplaces the container'sPipelineStepAnnotation. A validation kept as a second annotation on the container makes that call throwSequence contains more than one element, and a single one would be silently removed. Go and Python therefore add the step withPipeline.AddStep, the way the Docker Compose, Kubernetes and Azure environments register their own steps, which leaves the container's annotations alone.PublishAsDockerFileWithDockerfileWarnsFromValidationStepWhenPackagePathIsNotDefault(Go) andPublishAsDockerFileWithDockerfileThrowsFromValidationStepWhenEntrypointIsChanged(Python) cover it. The change touches no sharedAspire.Hostingcode and adds no public API.Go users whose custom Dockerfile already builds the requested package will see the warning and can silence it by setting an explicit container entrypoint or by renaming the Dockerfile so Aspire generates one. Python users with a custom Dockerfile who re-point the entrypoint with
WithEntrypoint(...)now need to do the same, as with JavaScript.Fixes #19070
Validation
.\restore.cmdpassed. Each row below isdotnet test --project tests\<Project>\<Project>.csproj --no-launch-profile -- [--filter-class <classes>] --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"on the final head, and each exited 0. A row with no classes ran the whole project.Aspire.Hosting.Go.TestsAspire.Hosting.Python.TestsAspire.Hosting.TestsPythonAppDeployPipelineTests,WithReferenceTestsAspire.Hosting.Foundry.TestsAddPythonAppwidely)The new tests cover Go (11 methods, one a three-row theory) and Python (14 methods, one a four-row theory): the Go warning and the Python throw for an existing Dockerfile, the explicit
PublishAsDockerFileentrypoint bypass, the validation step survivingPublishAsDockerFile(c => c.WithDockerfile(...)), resources excluded from the manifest, the validation step running before the image build, and the cases that must not warn or throw (Go".","./"and"./.", and Python restatingmain.pyas./main.py). The Go tests capture the pipeline step's log throughTestPipelineActivityReporter, assert the whole warning text, and assert that nothing is logged otherwise. One Azure Container Apps test inAspire.Hosting.Testsasserts the Deploy graph contains the Python validation step. A Verify snapshot covers Python publish without a Dockerfile afterWithEntrypoint(...). Python 3.14 was installed, so the[RequiresTools(["python"])]tests ran too.Not run on the dev machine: the Linux and macOS path assertions, and the rest of
Aspire.Hosting.Tests(the change touches no code in that project). GitHub CI covers them.Checklist
<remarks />and<code />elements on your triple slash comments?