Repository navigation
Stop persisting ambient NuGet policy into AppHost configs - #21373
Conversation
Separate C# project edits from temporary discovery overlays. Maintain selected channel entries without copying ambient mappings or introducing mapping clears, and let stable use ambient policy without adding Aspire mappings. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21373Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21373" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Critical NuGet mapping defects can leave non-Aspire dependencies without an eligible source or preserve inherited mappings to obsolete feeds, causing restores to fail or use the wrong feed.
4 open issues
What changed in this PR
This PR addresses #21362 by separating temporary NuGet discovery policy from persisted AppHost configuration, aiming to prevent generated projects from inheriting machine-specific feeds and mappings.
Changes:
- Adds dedicated AppHost persistence composition and mapping edits while preserving user-owned policy.
- Updates template creation and project updates to use the persistence path, including stable-channel cleanup.
- Adds regression coverage and revises snapshots and documentation for the new behavior.
| File | Description |
|---|---|
| tests/Aspire.Cli.Tests/TestServices/DotNetAppHostNuGetConfigTestHelper.cs | Uses the AppHost-specific configuration builder. |
| tests/Aspire.Cli.Tests/Templating/TemplateNuGetConfigServiceTests.cs | Tests selected-only persistence and stable policy preservation. |
| tests/Aspire.Cli.Tests/Snapshots/TemplateNuGetConfigServiceTests.CreateNuGetConfigIfMissingAsync_PreservesInheritedAndNestedConfigs.verified.txt | Removes copied inherited mappings. |
| tests/Aspire.Cli.Tests/Snapshots/TemplateNuGetConfigServiceTests.CreateNuGetConfig_PersistsOnlySelectedMappings_hasAmbientMappings=True_builtInScaffolding=True.verified.txt | Records built-in output with ambient mappings. |
| tests/Aspire.Cli.Tests/Snapshots/TemplateNuGetConfigServiceTests.CreateNuGetConfig_PersistsOnlySelectedMappings_hasAmbientMappings=True_builtInScaffolding=False.verified.txt | Records external-template output with ambient mappings. |
| tests/Aspire.Cli.Tests/Snapshots/TemplateNuGetConfigServiceTests.CreateNuGetConfig_PersistsOnlySelectedMappings_hasAmbientMappings=False_builtInScaffolding=True.verified.txt | Records built-in output without ambient mappings. |
| tests/Aspire.Cli.Tests/Snapshots/TemplateNuGetConfigServiceTests.CreateNuGetConfig_PersistsOnlySelectedMappings_hasAmbientMappings=False_builtInScaffolding=False.verified.txt | Records external-template output without ambient mappings. |
| tests/Aspire.Cli.Tests/Snapshots/Merge_WithSimpleNuGetConfig_ProducesExpectedXml.stable.verified.xml | Removes synthesized stable mappings. |
| tests/Aspire.Cli.Tests/Snapshots/Merge_WithSimpleNuGetConfig_ProducesExpectedXml.pr-1234.verified.xml | Records PR-channel mappings without a mapping clear. |
| tests/Aspire.Cli.Tests/Snapshots/Merge_WithSimpleNuGetConfig_ProducesExpectedXml.daily.verified.xml | Records daily mappings without a mapping clear. |
| tests/Aspire.Cli.Tests/Snapshots/Merge_WithExtraInternalFeedIncorrectlyMapped_ProducesExpectedXml.stable.verified.xml | Preserves user-owned internal-feed policy on stable. |
| tests/Aspire.Cli.Tests/Snapshots/Merge_WithExtraInternalFeedIncorrectlyMapped_ProducesExpectedXml.pr-1234.verified.xml | Preserves internal-feed policy alongside the PR feed. |
| tests/Aspire.Cli.Tests/Snapshots/Merge_WithDailyFeedWithExtraMappingsIsPreserved_ProducesExpectedXml.stable.verified.xml | Retains user mappings during stable selection. |
| tests/Aspire.Cli.Tests/Snapshots/Merge_WithDailyFeedWithExtraMappingsIsPreserved_ProducesExpectedXml.pr-1234.verified.xml | Retains user mappings during PR-channel selection. |
| tests/Aspire.Cli.Tests/Snapshots/Merge_WithDailyFeedWithExtraMappingsIsPreserved_ProducesExpectedXml.daily.verified.xml | Preserves existing daily-feed mappings and aliases. |
| tests/Aspire.Cli.Tests/Snapshots/Merge_WithBrokenSdkState_ProducesExpectedXml.stable.verified.xml | Removes synthesized stable mapping policy. |
| tests/Aspire.Cli.Tests/Snapshots/Merge_WithBrokenSdkState_ProducesExpectedXml.pr-1234.verified.xml | Removes the inserted mapping clear. |
| tests/Aspire.Cli.Tests/Snapshots/Merge_WithBrokenSdkState_ProducesExpectedXml.daily.verified.xml | Removes the inserted mapping clear. |
| tests/Aspire.Cli.Tests/Snapshots/Merge_ExtraPatternOnDailyFeedWhenOnPrFeedGetsConsolidatedWithOtherPatterns_ProducesExpectedXml.stable.verified.xml | Preserves existing patterns without stable additions. |
| tests/Aspire.Cli.Tests/Snapshots/Merge_ExtraPatternOnDailyFeedWhenOnPrFeedGetsConsolidatedWithOtherPatterns_ProducesExpectedXml.pr-1234.verified.xml | Records PR-channel output without a mapping clear. |
| tests/Aspire.Cli.Tests/Snapshots/Merge_ExtraPatternOnDailyFeedWhenOnPrFeedGetsConsolidatedWithOtherPatterns_ProducesExpectedXml.daily.verified.xml | Records daily output without a mapping clear. |
| tests/Aspire.Cli.Tests/Snapshots/DotNetAppHostNuGetConfigMergerTests.PrepareAsync_PersistenceReenablesSelectedInheritedSourceWithoutEnablingOtherSources.verified.xml | Preserves mapping inheritance when enabling a source. |
| tests/Aspire.Cli.Tests/Snapshots/DotNetAppHostNuGetConfigMergerTests.PrepareAsync_PersistenceMasksOnlySurvivingRetiredSources_locallyDefined=True_inheritedDefined=True_clearSources=True.verified.xml | Updates section ordering for cleared-source retirement. |
| tests/Aspire.Cli.Tests/Snapshots/DotNetAppHostNuGetConfigMergerTests.PrepareAsync_PersistenceMasksOnlySurvivingRetiredSources_locallyDefined=True_inheritedDefined=True_clearSources=False.verified.xml | Updates ordering for local and inherited retirement. |
| tests/Aspire.Cli.Tests/Snapshots/DotNetAppHostNuGetConfigMergerTests.PrepareAsync_PersistenceMasksOnlySurvivingRetiredSources_locallyDefined=True_inheritedDefined=False_clearSources=False.verified.xml | Updates ordering for local-only retirement. |
| tests/Aspire.Cli.Tests/Snapshots/DotNetAppHostNuGetConfigMergerTests.PrepareAsync_PersistenceMasksOnlySurvivingRetiredSources_locallyDefined=False_inheritedDefined=True_clearSources=False.verified.xml | Updates ordering for inherited-source retirement. |
| tests/Aspire.Cli.Tests/Snapshots/DotNetAppHostNuGetConfigMergerTests.PrepareAsync_DefersExistingConfigChanges.verified.xml | Removes synthesized ambient mappings from proposed content. |
| tests/Aspire.Cli.Tests/Snapshots/DotNetAppHostNuGetConfigMergerTests.PrepareAsync_ChannelRoundTripDoesNotAccumulateProjectionMasks.verified.xml | Removes ambient catch-all and mapping clear. |
| tests/Aspire.Cli.Tests/Snapshots/DotNetAppHostNuGetConfigMergerTests.CreateOrUpdateAsync_PreservesUserMappingsForSelectedPattern.verified.xml | Records preservation of competing user mappings. |
| tests/Aspire.Cli.Tests/Snapshots/DotNetAppHostNuGetConfigMergerTests.CreateOrUpdateAsync_DoesNotSynthesizeMappingsForExistingSources.verified.xml | Records selected-only mapping creation. |
| tests/Aspire.Cli.Tests/Snapshots/DotNetAppHostNuGetConfigMergerTests.CreateOrUpdateAsync_CreatesConfigFromMappings_WhenNoExistingConfig.verified.xml | Omits the mapping clear in new configuration. |
| tests/Aspire.Cli.Tests/Projects/ProjectUpdaterNuGetConfigurationTests.cs | Updates ambient-policy and CLI-owned cleanup scenarios. |
| tests/Aspire.Cli.Tests/NuGet/NuGetConfigurationTests.cs | Tests separate operation and persistence policies. |
| tests/Aspire.Cli.Tests/NuGet/NuGetConfigurationQueryTests.cs | Checks discovery and persisted source eligibility separately. |
| tests/Aspire.Cli.Tests/NuGet/BundleNuGetServiceTests.cs | Separates preview assertions from persistence expectations. |
| tests/Aspire.Cli.Tests/DotNet/DotNetAppHostNuGetConfigMergerTests.cs | Tests user-policy preservation and stable cleanup. |
| src/Aspire.Cli/Templating/TemplateNuGetConfigService.cs | Routes new configuration through the AppHost merger. |
| src/Aspire.Cli/Projects/ProjectUpdater.cs | Uses dedicated stable persistence composition. |
| src/Aspire.Cli/NuGet/NuGetConfigurationBuilder.cs | Shares CLI-source identification and removes catch-all repair. |
| src/Aspire.Cli/NuGet/NuGetConfiguration.cs | Stores a separate AppHost persistence plan. |
| src/Aspire.Cli/NuGet/BundleNuGetService.cs | Adds AppHost composition and delegates persistence writing. |
| src/Aspire.Cli/DotNet/DotNetAppHostNuGetConfigMerger.cs | Applies targeted mapping edits to proposed configuration. |
| src/Aspire.Cli/DotNet/DotNetAppHostNuGetConfigBuilder.cs | Composes selected mappings and CLI-owned cleanup. |
| docs/specs/polyglot-integration-restore.md | Documents discovery versus persistence behavior. |
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. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Reject configuration edits that borrow user-owned aliases or shadow inherited mappings, while allowing local CLI-owned maintenance and byte-identical no-ops. Report planned refusals as normal creation failures in new and init, and cover the behavior with focused regressions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Critical fallback-source persistence issues can break dependency restoration on other machines and unintentionally re-enable user-disabled feeds.
5 open issues
1 resolved since last review
1 file not reviewed
src/Aspire.Cli/Resources/UpdateCommandStrings.Designer.cs: Generated file
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. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Stop persisting default mappings and disabled-source overrides. Reject edits that require inherited old-channel overrides or explicitly disabled sources while preserving local maintenance and byte-identical no-ops. Add cross-user alias and configuration-preservation regressions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Ancestor-config cleanup can delete unrelated package-source mappings and sources hidden by local overrides, breaking package routing for other projects.
4 open issues
3 resolved since last review
1 file not reviewed
src/Aspire.Cli/Resources/UpdateCommandStrings.Designer.cs: Generated file
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. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Remove implicit channel fallback sources, leave package-source mapping disabled when ambient policy has no mappings, and keep channel retirement limited to local records. Update creation, restore, and snapshot regressions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve the regenerated UpdateCommandStrings accessors from main and retain the channel-feed conflict resource without duplicate properties. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🔵 Needs a closer look
Native NuGet hierarchy and persistence changes still need runtime confirmation because two updater native-restore scenarios and the changed mapped/unmapped CLI E2E paths remain unvalidated.
No open issues 🎉
1 file not reviewed
src/Aspire.Cli/Resources/UpdateCommandStrings.Designer.cs: Generated file
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. |
|
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 <223556219+Copilot@users.noreply.github.com>
Tests selector3 / 100 PR test projects · 5 PR jobs, from 100 changed files. Selected PR test projects (3 / 100)
Selected PR jobs (5)
How these were chosen — grouped by what changed📦 affected project 🔧 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 Job reasons
Selection computed for commit |
There was a problem hiding this comment.
🔵 Needs a closer look
The changed NuGet persistence and discovery policies need runtime confirmation because two native updater restore scenarios were excluded and mapped/unmapped CLI E2E tests remain unexecuted.
No open issues 🎉
1 file not reviewed
src/Aspire.Cli/Resources/UpdateCommandStrings.Designer.cs: Generated file
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. |
PR Smoke Testing ReportPR Information
Artifact Version Verification
The standard dogfood command was executed inside the repository container runner: curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21373The installer succeeded. Its actual reported install path was used for every subsequent CLI command. No installer repair, bundle repair, or host-profile modification was performed. Changes AnalyzedPrincipal Files
The complete change list is retained as Change Categories
Test EnvironmentThe container used an isolated CLI install and per-scenario NuGet package caches. Parent configurations included a working internal mirror and, where relevant, an empty private feed, existing mappings, and orphaned disabled-source records. The minimal container needed a .NET SDK. The SDK was installed under Initial Docker availability and test-environment setup errors were corrected before the successful scenario runs. They are not classified as PR failures. Container Scenarios Executed1. Fresh C# starter with mapping disabledCoverage: Happy path and mapping-mode boundary Created a fresh starter with a parent configuration that had registered ambient feeds but no effective package-source mappings. Explicitly selected the downloaded PR hive and installed version: "$cli" new aspire-starter \
--name PrUnmapped --output /workspace/unmapped/PrUnmapped \
--source "$hive" --version "$version" \
--test-framework None --use-redis-cache false --localhost-tld false \
--suppress-agent-init --use-config-source false --non-interactiveVerified:
Evidence: 2. Fresh C# starter with mapping already enabledCoverage: Happy path and inherited-policy preservation Used a separate fresh project with parent mappings for the ambient mirror and private package patterns. Verified:
Evidence: 3. File-based C# initialization and local-only retirementCoverage: Happy path, inherited-source boundary, and no-op Ran: "$cli" init --language csharp --file-based \
--suppress-agent-init --use-config-source false --non-interactiveThe parent and local configuration both defined Verified:
Evidence: 4. Solution/project-based C# initializationCoverage: Happy path and removal-only retirement Created a fresh solution, initialized C#, built the generated AppHost project, and reran initialization. Verified the same retirement, parent-preservation, disabled-section preservation, mapping-mode, and byte-identical rerun properties as the file-based scenario. Evidence: 5. Refuse a mapping write borrowing an inherited user aliasCoverage: Unhappy path Configured the PR package directory under a parent-owned Expected and observed: Exit code Evidence: 6. Refuse an explicitly disabled selected feedCoverage: Unhappy path Configured the selected PR feed under an explicitly disabled parent entry and attempted fresh C# project creation. Expected and observed: Exit code Evidence: CLI CI Evidence at the Manual Smoke-Tested CommitActual TRX results from run 40937836793, at
These are platform-specific test occurrences, not unique test counts. Targeted ownership, cleanup, no-op, mapping-mode, and concurrent-write cases were confirmed passed in the artifacts.
Both The update-ordering case was skipped because CI installed a Evidence: Downstream Extension E2E Follow-Up: ResolvedThe earlier run at Fixture correctionThe failing setup registered the PR hive under inherited alias Commit A separate fresh container proof with the same inherited alias and mapping disabled also passed project creation and native build, with byte-identical parent configuration. The subsequent CI rerun provides actual Extension Host confirmation of the fixture correction. Actual rerun results at the latest headRun 40953093397 completed successfully at
Both Final Test Results and Final Results succeeded. Focused local validation of the fixture change also passed:
Transient failure cleared by retryWindows launch-profiles initially timed out during TypeScript Node.js dependency installation in the earlier run. Attempt 2 ran all three tests successfully on that unchanged commit. Both Linux and Windows launch-profile jobs are also green in the latest run. This was consistent with transient install/timing noise; no timeout or product change was made. Remaining Limitations and Separate Issue
Summary
Overall ResultTARGETED SMOKE VALIDATION PASSED; DOWNSTREAM FIXTURE FAILURES RESOLVED. No additional product regression was identified in the smoke scenarios. The earlier downstream failures were corrected in the shared fixture and confirmed resolved by actual passing Extension Host tests at the latest head. The coverage and pending-check limitations above remain explicit; this is not a claim that every possible scenario or PR check has been validated. Evidence, Posting, and Inspection Status
|
|
Pull request created: #1997
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#1997 targeting Updated Note This draft PR needs human review before merging. |


Description
Creating or updating an AppHost can copy machine-specific NuGet feeds and mappings into the project's
nuget.config. Persisting the temporary discovery overlay also introduces a mapping<clear />, replacing inherited policy and making generated projects depend on the generating machine's configuration.Separate C# project persistence from temporary discovery policy. Persist the selected integration feed configuration as needed and maintain CLI-owned local entries without copying ambient configuration or inventing default package routing.
NuGetClientremains unchanged.<clear />. Existing user-authored clears anddisabledPackageSourcesentries remain untouched.Fixes #21362
Examples
When ambient configuration has no package-source mappings, a newly generated configuration adds only the selected source. It does not enable mapping or serialize the generating machine's other feeds:
When mapping is already enabled, the generated file also contains the integration binding below. Ambient mappings remain inherited rather than being copied into this file:
Ordinary stable selection does not create a redundant configuration. Existing local CLI-owned channel records can be retired without changing parent configuration or disabled-source entries.
Validation
Final published-tree validation on macOS arm64: 1,511 passed, 0 failed, 1 skipped across the affected CLI test classes, including the dedicated merger snapshots, creation and initialization, channel resolution, updater behavior, and native restore. The offline native-restore regression verifies that a configuration without mappings can restore packages from both ambient and selected local feeds. Generated snapshot changes were reviewed.
Exact broad test command
Result: 1,511 passed, 0 failed, 1 skipped.
The relative-source scenario excluded from the broad run also passed separately on the current head:
Result: 1 passed, 0 failed.
The two excluded updater native-restore scenarios were not validated in the final run. Quarantined and outerloop tests were excluded. CLI E2E tests were not run locally; CI/E2E validation of
5a5901bc08remains outstanding.Checklist
<remarks />and<code />elements on your triple slash comments?