Skip to content

[release/13.3] Avoid AppHost discovery when config path is valid#16680

Open
adamint wants to merge 3 commits intorelease/13.3from
backport/pr-16653-to-release/13.3
Open

[release/13.3] Avoid AppHost discovery when config path is valid#16680
adamint wants to merge 3 commits intorelease/13.3from
backport/pr-16653-to-release/13.3

Conversation

@adamint
Copy link
Copy Markdown
Member

@adamint adamint commented May 1, 2026

Backport of #16653 to release/13.3

/cc @adamint

adamint and others added 3 commits May 1, 2026 21:48
Validate configured AppHost paths before using them and skip recursive discovery for normal CLI resolution when the configured path is already a valid AppHost. Preserve candidate listing behavior so extension commands can still enumerate all AppHost candidates.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reverts an unintended verbosity change so users with a stale legacy
.aspire/settings.json don't see a 'AppHost was specified but doesn't
exist' warning on every aspire run when the CLI is going to fall
back to discovery anyway.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add Throw-mode variant of UseOrFindAppHostProjectFileUsesValidSettingsWithoutScanning
  to prove recursive discovery is also skipped for non-interactive/JSON callers.
- Add fast-path test with a configured guest AppHost (apphost.ts) and a throwing
  language discovery to cover the production guest-AppHost scenario from the issue.
- Add a parameterized fallback test that verifies an existing-but-invalid configured
  AppHost (IsUnsupported / IsPossiblyUnbuildable) falls back to discovery.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 1, 2026 21:53
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 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 -- 16680

Or

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

Copy link
Copy Markdown
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

Backports the AppHost resolution behavior to avoid recursive AppHost discovery (and its expensive scanning) when a valid AppHost path is already configured in aspire.config.json, while preserving “candidate listing” behavior when callers request it.

Changes:

  • Short-circuits normal CLI AppHost resolution to use a validated configured AppHost path without scanning (except when MultipleAppHostProjectsFoundBehavior.None is used).
  • Improves warning logs when a configured AppHost path is invalid by including unsupported/unbuildable reasons and an optional validation message.
  • Ensures SelectedProjectFile is always present in AllProjectFileCandidates, even when the selected AppHost lies outside the discovery scope.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/Aspire.Cli.Tests/Projects/ProjectLocatorTests.cs Adds/updates unit tests covering “use valid configured path without scanning”, fallback-to-discovery for invalid configured paths, and candidate-listing behaviors.
src/Aspire.Cli/Projects/ProjectLocator.cs Implements the early-return path for valid configured AppHost resolution (skipping scanning) and tightens candidate list invariants + improved invalid-settings diagnostics.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

🎬 CLI E2E Test Recordings — 66 recordings uploaded (commit e9b4ed0)

View all recordings
Status 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
Banner_NotDisplayedWithNoLogoFlag ▶️ 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
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain ▶️ View Recording
DashboardRunWithOtelTracesReturnsNoTraces ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ▶️ View Recording
DoListStepsShowsPipelineSteps ▶️ View Recording
DocsCommand_RendersInteractiveMarkdownFromLocalSource ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain ▶️ 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
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
InteractiveCSharpInitCreatesExpectedFiles ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
OtelLogsReturnsStructuredLogsFromStarterAppCore ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreGeneratesSdkFiles_WithConfiguredToolchain ▶️ View Recording
RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #25234789012

@joperezr
Copy link
Copy Markdown
Member

joperezr commented May 4, 2026

Low risk, improves the experience. @adamint apart from unit tests added here did we do manual validation as well of these changes on top of 13.3?

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

Labels

Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants