Skip to content

Fix migration from .aspire/settings.json to aspire.config.json#15524

Merged
mitchdenny merged 2 commits intomainfrom
fix/config-migration-from-settings-json
Mar 24, 2026
Merged

Fix migration from .aspire/settings.json to aspire.config.json#15524
mitchdenny merged 2 commits intomainfrom
fix/config-migration-from-settings-json

Conversation

@mitchdenny
Copy link
Member

Description

Fix migration from .aspire/settings.json to aspire.config.json when upgrading from Aspire 13.1 (or lower) to 13.2.

Problem: In ProjectLocator.UseOrFindAppHostProjectFileAsync(), when the AppHost was found from the legacy .aspire/settings.json, the method returned early without calling CreateSettingsFileAsync. The createSettingsFile check was only reachable via the directory-scanning fallback path, so a working .aspire/settings.json paradoxically prevented its own migration to aspire.config.json.

Fix: Call CreateSettingsFileAsync when createSettingsFile is true and the AppHost is found from settings, ensuring the legacy config is migrated.

Validation: All 1681 CLI tests pass, including a new regression test that verifies the migration occurs when the AppHost is discovered from legacy settings.

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
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

When the AppHost was found from legacy .aspire/settings.json, the
UseOrFindAppHostProjectFileAsync method returned early without calling
CreateSettingsFileAsync, so the migration to aspire.config.json never
triggered. This fix ensures CreateSettingsFileAsync is called when
createSettingsFile is true and the AppHost is found from settings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 24, 2026 09:22
@github-actions
Copy link
Contributor

github-actions bot commented Mar 24, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15524

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15524"

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes migration from legacy .aspire/settings.json to aspire.config.json during AppHost discovery, ensuring the migration runs even when the AppHost is found via legacy settings (not only via directory scanning).

Changes:

  • Update ProjectLocator.UseOrFindAppHostProjectFileAsync to call CreateSettingsFileAsync when the AppHost is resolved from settings and createSettingsFile is true.
  • Add a regression test intended to verify migration occurs when the AppHost is discovered from legacy .aspire/settings.json.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Aspire.Cli/Projects/ProjectLocator.cs Ensures settings/migration logic runs when the AppHost is found via settings-derived paths.
tests/Aspire.Cli.Tests/Projects/ProjectLocatorTests.cs Adds a regression test for legacy-settings-driven migration behavior.

Address Copilot review feedback: compute appHostPath relative to
.aspire/ directory (not workspace root), normalize to forward slashes,
and add a decoy project to ensure the legacy-settings resolution path
is actually exercised rather than falling through to directory scanning.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor

🎬 CLI E2E Test Recordings — 49 recordings uploaded (commit 96860e1)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23485742793

@mitchdenny mitchdenny merged commit 481cf5a into main Mar 24, 2026
249 checks passed
@mitchdenny mitchdenny deleted the fix/config-migration-from-settings-json branch March 24, 2026 11:15
@mitchdenny
Copy link
Member Author

/backport to release/13.2

@github-actions
Copy link
Contributor

Started backporting to release/13.2 (link to workflow run)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants