Fix misleading AppHost build failure diagnostics - #19082
Fix misleading AppHost build failure diagnostics#19082Ella Hathaway (ellahathaway) wants to merge 5 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0f00829a-32fc-44f6-bfb8-4310c86a460c
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0f00829a-32fc-44f6-bfb8-4310c86a460c
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0f00829a-32fc-44f6-bfb8-4310c86a460c
There was a problem hiding this comment.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Note
This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 19082Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 19082" |
Classify explicit AppHost directories containing only unbuildable candidates as build failures, and add unit and CLI regression coverage for the missing-SDK case. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0f00829a-32fc-44f6-bfb8-4310c86a460c
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/Aspire.Cli/Commands/RunCommand.cs:589
- The new
build_failedtelemetry classification is not covered by the added tests: the locator tests stop at the exception/exit-code mapping, and the E2E test only checks terminal output. SinceRunCommandTestsalready verifiesErrorTypetags, add a case whose locator throwsAppHostsMayNotBeBuildableand assert that the run activity recordsbuild_failed; otherwise this advertised telemetry behavior can regress without any test failing.
runActivity?.SetTag(
TelemetryConstants.Tags.ErrorType,
ex.FailureReason is ProjectLocatorFailureReason.AppHostsMayNotBeBuildable ? "build_failed" : "project_not_found");
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
…n failure An AppHost can exist and still fail MSBuild evaluation, most commonly when Aspire.AppHost.Sdk cannot be resolved. ProjectLocator treated that signal (IsPossiblyUnbuildable) as "no such project", so the user was told the file did not exist, or that no AppHosts were found, and never saw the MSB4236 that explained the real problem. Keep the selection instead. An explicitly named file, an explicitly named directory holding one candidate, and a configured aspire.config.json path are all deliberate user choices, so honor them and let the command's existing build path print the diagnostics it already collects. That path needs no changes: it already stashes build output, reports FailedToBuildArtifacts, and displays the collected lines. Ambient discovery is deliberately unchanged. Finding only unbuildable candidates while scanning is still AppHostsMayNotBeBuildable with FailedToFindProject, because AppHostConnectionResolver.IsProjectResolutionError keys off that exit code to tell "AppHost not running" apart from "no project resolved". Remapping it makes stop/logs/describe/ps emit success-shaped output. An unverified selection is never written back to settings, since a candidate kept only because MSBuild failed was never confirmed to be an AppHost and would otherwise be silently reused by later ambient invocations. Fixes microsoft#19035 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c56ab082-7689-4734-9d39-dbca4d4e1470
There was a problem hiding this comment.
Review details
Suppressed comments (1)
src/Aspire.Cli/Projects/ProjectLocator.cs:604
- On case-sensitive macOS volumes,
OrdinalIgnoreCasetreats sibling directories such asServicesandservicesas the same subtree. Because discovery injects candidates from parent configuration,--apphost ./Servicescan therefore auto-select an unverified configured project under./services, defeating the containment check this helper was added to enforce. Please determine case sensitivity for the actual volume (or compare filesystem identity) rather than assuming all macOS paths are case-insensitive.
var pathComparison = environment.IsWindows() || environment.IsMacOS()
? StringComparison.OrdinalIgnoreCase
: StringComparison.Ordinal;
- Files reviewed: 7/7 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Description
An AppHost can exist and still fail MSBuild evaluation — most commonly when
Aspire.AppHost.Sdkcannot be resolved.ProjectLocatortreated that signal (IsPossiblyUnbuildable) as "no such project", so the user was told the file did not exist, or that no AppHosts were found, and never saw theMSB4236that explained the real problem.This keeps the selection instead. An explicitly named file, an explicitly named directory holding a single candidate, and a configured
aspire.config.jsonpath are all deliberate user choices, so they are honored and the command's existing build path prints the diagnostics it already collects. That path needed no changes — it already stashes build output, reportsFailedToBuildArtifacts, and displays the collected lines. The entire fix is contained inProjectLocator.cs.User-facing behavior
Before, for an AppHost whose SDK cannot be resolved:
After, both paths reach the build and report what is actually wrong:
What deliberately did not change
Ambient discovery. Finding only unbuildable candidates while scanning the working directory is still
AppHostsMayNotBeBuildablemapped toFailedToFindProject.AppHostConnectionResolver.IsProjectResolutionErrorkeys off that exit code to tell "AppHost not running" apart from "no project resolved"; remapping it makesstop/logs/describe/psemit success-shaped output.AppHostConnectionResolverTestsguards this.Unsupported projects.
IsUnsupported(for example a guest language unavailable in the current environment) still falls back to discovery. OnlyIsPossiblyUnbuildableis reinterpreted — the two were previously conflated in one theory, which is now split into two focused tests.Ambiguous directories. An explicit directory containing more than one unbuildable candidate is a genuine ambiguity rather than a selection, so it still fails resolution. Candidates injected into the walk from a parent directory's config are excluded from that count, so
--apphost ./some-dirnever auto-selects a project that is not under./some-dir.Settings are never written from an unverified selection. A candidate kept only because MSBuild failed was never confirmed to be an AppHost; persisting it would let later ambient invocations silently reuse the guess.
Validation
ProjectLocatorTests— 98 tests (97 passed, 1 Windows-only skip), including 8 new regression tests covering the explicit-file, explicit-directory, configured, out-of-directory, and multiple-healthy-candidate paths.RunCommandTests,UpdateCommandTests,AppHostConnectionResolverTests,AddCommandTests— 227/227.RunReportsMissingSdkAsBuildFailureForDotNetAppHost) run in Docker against a locally built CLI. The asciinema recording confirmsMSB4236reaches the terminal, the shell reports exit code 6, and neither of the two misleading messages appears.Fixes #19035
Checklist
<remarks />and<code />elements on your triple slash comments?