You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Record Git template provenance in generated aspire.config.json - #21833
Generated projects currently lose the Git origin of their selected template. This adds provenance.template.repository, provenance.template.sha, and provenance.template.path to the output-root aspire.config.json after successful Git-backed template generation.
This is a separate draft follow-up to the feedback around #21831, based on main, with no dependency on that PR or picker-heading changes.
The recorded SHA is the already-resolved commit used for the verified checkout, including cached checkouts and callbacks selected before a branch moves. The path identifies the selected template's directory containing .template.config, not the broader search directory. Generation does not perform another Git lookup. The write uses the existing workspace lock and atomic JSON writer, preserving template-owned settings and unrelated provenance fields. A write error is reported before the template success message. Persisted filesystem paths use / separators, including absolute local Windows repository paths.
Fixes # (issue)
User-facing usage
Existing Git-template invocations now produce origin metadata automatically:
aspire new --template-repository https://github.com/example/templates.git --template-path templates/my-template --name MyApp --output ./MyApp
This is generation metadata, nottemplateSources registration or a configSource binding. Directory and built-in templates intentionally remain unchanged because they have no verified Git acquisition metadata. Failed, rejected, or cancelled generation writes no provenance. Typed configuration persistence, CLI configuration schema, the generated extension schema's provenance section, and the directly related documentation are updated. Existing extension input routing already covers extension/**; no test-selection routing change is needed.
Validation
Passed on macOS: 1,025 tests passed, 6 skipped, 0 failed, including real local Git checkout/ref/cache scenarios, resolved SHA/path assertions, relative/absolute local-path normalization, configuration preservation, invalid configuration, cancellation, engine/computed-generation failures, credentials, built-in/directory behavior, schema, and configuration-source materialization.
Passed in a Linux ARM64 Docker test runner: all 4 CustomTemplateTests scenarios, using the current branch's self-contained CLI archive and a no-.NET-SDK polyglot test image. Both interactive and unattended repository generation assert the exact fixture repository, actual Git commit, and selected template path before snapshot scrubbing. The fixture makes only its generated config readable for host-side verification; production config permissions remain unchanged.
dotnet build tests/Aspire.Cli.EndToEnd.Tests/Aspire.Cli.EndToEnd.Tests.csproj --no-restore — passed with no warnings. node extension/scripts/generate-schema.js — passed; retained only the generated provenance delta to avoid unrelated pre-existing schema drift. Live aspire config info --json was checked against the extension schema for the exact repository, sha, path shape. git diff --check — passed. Generated snapshots were reviewed and the final runs passed.
The standard localhive.sh packaging attempt was blocked by missing pwsh, so the Linux CLI was published directly for the local E2E run. Repository E2E cases cannot reach the host loopback Git server from Docker Desktop on macOS; running the test runner itself on Linux with shared Docker networking avoids that local limitation without changing product or test networking. Windows execution and the full product suite were not run locally.
CI passed for final commit 10501fb4fe1d5fe931cf6eba4b98e8b7606b878f: https://github.com/microsoft/aspire/actions/runs/42169003734. The final current-head check snapshot is 205 successful checks, 15 skipped, none failed or pending. Both previously failing groups passed: Windows CLI unit tests and Linux CustomTemplateTests. Native hosting validation and the other current-head workflows also passed. The first attempt hit an unrelated 45-minute timeout in the shared E2E Docker image build during apt package installation; rerunning that job and its dependents succeeded without infrastructure changes. No cloud resources were provisioned. No visual UI change is included.
Security considerations
Repository URLs are persisted without passwords, HTTPS userinfo, query strings, or fragments; SSH usernames remain valid location metadata. Local Git repository paths are made absolute and normalized to / separators. The configuration write rejects symbolic links and uses the existing lock/atomic writer. Origin metadata does not authenticate a template, grant trust, add inherited settings, or authorize execution. No additional network operations or template post-actions are introduced. A formal security review has not been performed.
Checklist
Is this feature complete?
Yes. Ready to ship.
No. Follow-up changes expected.
Are you including unit tests for the changes and scenario tests if relevant?
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
No
Does the change make any security assumptions or guarantees?
Yes
If yes, have you done a threat model and had a security review?
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Provenance generation can bypass legacy template settings and prevent migration, while Windows snapshot scrubbing leaves machine-specific repository paths that fail comparison.
Records Git template origins in generated projects so users can identify the repository, resolved commit, and selected template directory. This is separate from picker-heading changes and does not register template sources or enable configuration inheritance.
Changes:
Carries verified checkout metadata through generation and merges provenance before reporting success.
Adds typed configuration support, schema entries, and documentation.
Extends tests and snapshots for commit pinning, configuration preservation, credential removal, and failure handling.
For a direct --template-repository git+ssh://git@example.test/templates.git (or ssh+git://...), this removes the SSH username and records a different repository location. GitCommandRunner.UsesSsh already recognizes both schemes as SSH, and dropping git@ can make the recorded URL unusable on servers that require that account. Preserve the username for those two SSH schemes as well, while continuing to remove passwords.
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
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
Generated projects currently lose the Git origin of their selected template. This adds
provenance.template.repository,provenance.template.sha, andprovenance.template.pathto the output-rootaspire.config.jsonafter successful Git-backed template generation.This is a separate draft follow-up to the feedback around #21831, based on
main, with no dependency on that PR or picker-heading changes.The recorded SHA is the already-resolved commit used for the verified checkout, including cached checkouts and callbacks selected before a branch moves. The path identifies the selected template's directory containing
.template.config, not the broader search directory. Generation does not perform another Git lookup. The write uses the existing workspace lock and atomic JSON writer, preserving template-owned settings and unrelated provenance fields. A write error is reported before the template success message. Persisted filesystem paths use/separators, including absolute local Windows repository paths.Fixes # (issue)
User-facing usage
Existing Git-template invocations now produce origin metadata automatically:
The generated configuration includes:
{ "provenance": { "template": { "repository": "https://github.com/example/templates.git", "sha": "0123456789abcdef0123456789abcdef01234567", "path": "templates/my-template" } } }This is generation metadata, not
templateSourcesregistration or aconfigSourcebinding. Directory and built-in templates intentionally remain unchanged because they have no verified Git acquisition metadata. Failed, rejected, or cancelled generation writes no provenance. Typed configuration persistence, CLI configuration schema, the generated extension schema's provenance section, and the directly related documentation are updated. Existing extension input routing already coversextension/**; no test-selection routing change is needed.Validation
Passed on macOS: 1,025 tests passed, 6 skipped, 0 failed, including real local Git checkout/ref/cache scenarios, resolved SHA/path assertions, relative/absolute local-path normalization, configuration preservation, invalid configuration, cancellation, engine/computed-generation failures, credentials, built-in/directory behavior, schema, and configuration-source materialization.
Passed in a Linux ARM64 Docker test runner: all 4
CustomTemplateTestsscenarios, using the current branch's self-contained CLI archive and a no-.NET-SDK polyglot test image. Both interactive and unattended repository generation assert the exact fixture repository, actual Git commit, and selected template path before snapshot scrubbing. The fixture makes only its generated config readable for host-side verification; production config permissions remain unchanged.dotnet build tests/Aspire.Cli.EndToEnd.Tests/Aspire.Cli.EndToEnd.Tests.csproj --no-restore— passed with no warnings.node extension/scripts/generate-schema.js— passed; retained only the generated provenance delta to avoid unrelated pre-existing schema drift. Liveaspire config info --jsonwas checked against the extension schema for the exactrepository,sha,pathshape.git diff --check— passed. Generated snapshots were reviewed and the final runs passed.The standard
localhive.shpackaging attempt was blocked by missingpwsh, so the Linux CLI was published directly for the local E2E run. Repository E2E cases cannot reach the host loopback Git server from Docker Desktop on macOS; running the test runner itself on Linux with shared Docker networking avoids that local limitation without changing product or test networking. Windows execution and the full product suite were not run locally.CI passed for final commit
10501fb4fe1d5fe931cf6eba4b98e8b7606b878f: https://github.com/microsoft/aspire/actions/runs/42169003734. The final current-head check snapshot is 205 successful checks, 15 skipped, none failed or pending. Both previously failing groups passed: Windows CLI unit tests and LinuxCustomTemplateTests. Native hosting validation and the other current-head workflows also passed. The first attempt hit an unrelated 45-minute timeout in the shared E2E Docker image build during apt package installation; rerunning that job and its dependents succeeded without infrastructure changes. No cloud resources were provisioned. No visual UI change is included.Security considerations
Repository URLs are persisted without passwords, HTTPS userinfo, query strings, or fragments; SSH usernames remain valid location metadata. Local Git repository paths are made absolute and normalized to
/separators. The configuration write rejects symbolic links and uses the existing lock/atomic writer. Origin metadata does not authenticate a template, grant trust, add inherited settings, or authorize execution. No additional network operations or template post-actions are introduced. A formal security review has not been performed.Checklist
<remarks />and<code />elements on your triple slash comments?