Repository navigation
[release/17.0] Persist stable AppHost ports and add worktree isolation - #22044
Closed
Mitch Denny (mitchdenny) wants to merge 1 commit into
Closed
Mitch Denny (mitchdenny) wants to merge 1 commit into
Mitch Denny (mitchdenny) wants to merge 1 commit into
Conversation
## Description
Generated public ports are currently stable only in a few special cases,
which means endpoint addresses can change across AppHost restarts and
linked Git worktrees require explicit isolation. This change introduces
a consistent persistent port model for both C# and polyglot AppHosts.
Generated public ports are stored in an AppHost-local key/value state
file under `.aspire/state`. The state store uses cross-process locking,
atomic replacement, per-value schema versioning, and a product-owned
`.gitignore`. Port allocation continues to treat executable target ports
as transient, while preserving generated public ports that form the
user-observable endpoint identity.
The implementation also:
- migrates existing `Resources:<resource>:<endpoint>:port` user-secret
values when first encountered, without writing new allocations back to
user secrets
- adds `features.gitWorktreeIsolationEnabled` to automatically use
isolated mode for AppHosts in linked Git worktrees, while preserving
explicit `--isolated true|false` precedence
- adds `portAllocation.persistInIsolatedMode` so isolated runs can opt
into stable persisted ports
- projects the AppHost-relative port policy consistently into managed C#
and polyglot AppHosts
### User-facing usage
```json
{
"features": {
"gitWorktreeIsolationEnabled": true
},
"portAllocation": {
"persistInIsolatedMode": true
}
}
```
By default, isolated mode continues to skip persisted allocations.
Setting `persistInIsolatedMode` to `true` gives each AppHost/worktree
identity stable generated ports across restarts.
No additional dependencies are required.
### Validation
- `dotnet test --project
tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-build
--no-launch-profile -- --filter-class "*.DcpExecutorTests"
--filter-not-trait "quarantined=true" --filter-not-trait
"outerloop=true"` - passed (314 succeeded, 1 platform-specific skip)
- `dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj
--no-build --no-launch-profile -- --filter-class
"*.AspireConfigFileTests" --filter-not-trait "quarantined=true"
--filter-not-trait "outerloop=true"` - passed (41 succeeded, 1
platform-specific skip)
- `./build.sh --build /p:SkipNativeBuild=true` - passed
- CLI end-to-end coverage was added for C# and TypeScript
linked-worktree restart stability; it was not run locally
Fixes #20653
## Checklist
- Is this feature complete?
- [x] Yes. Ready to ship.
- [ ] 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: Copilot App <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit 168a8b4)
14 tasks
This comment has been minimized.
This comment has been minimized.
Contributor
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Mitch Denny (mitchdenny)
marked this pull request as ready for review
November 10, 2026 05:13
Member
Author
|
Approved for inclusion in release/17.0. Do not merge yet. |
Mitch Denny (mitchdenny)
requested review from
Eric Erhardt (eerhardt),
Ankit Jain (radical) and
Sébastien Ros (sebastienros)
as code owners
November 10, 2026 06:14
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-46-pr21013
branch
from
November 10, 2026 06:15
d9158bc to
5dfe984
Compare
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22044Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22044" |
This comment has been minimized.
This comment has been minimized.
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-46-pr21013
branch
from
November 10, 2026 06:21
5dfe984 to
d9158bc
Compare
Contributor
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-46-pr21013
branch
from
November 10, 2026 07:59
d9158bc to
5dfe984
Compare
Mitch Denny (mitchdenny)
force-pushed
the
mitchdenny-backport-17-0-46-pr21013
branch
from
November 10, 2026 08:32
5dfe984 to
d9158bc
Compare
Contributor
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Backport of #21013 to
release/17.0(cherry-picked from 168a8b4 with no modifications).Layer 46 of 55 in the release/17.0 backport stack; stacked on #22043.
Backport recommendation: No — Feature.
Validation: Stable patch IDs match the original commit. Builds/tests not run for this unchanged cherry-pick.
Backport of #21013
Checklist
<remarks />and<code />elements on your triple slash comments?