[release/13.4] Enrich AppHost codegen TypeLoadException diagnostics#17556
Conversation
When the installed Aspire CLI ships an �spire-managed server whose bundled Aspire.Hosting.dll is on a different build than the user-restored Aspire.Hosting.CodeGeneration.TypeScript / Aspire.TypeSystem DLLs, reflection-based codegen can throw an empty TypeLoadException that travels back to the CLI with no message and triggers a 60-second backchannel timeout. This change adds three coordinated improvements: 1. Server-side: wrap reflection-load exceptions (TypeLoadException, MissingMethodException, MissingFieldException, BadImageFormatException, FileLoadException, ReflectionTypeLoadException) in a LocalRpcException with a safe, language-agnostic Message and a structured ErrorData payload (TypeName, MemberName, loaded ATS assemblies + informational versions, runtime Aspire.Hosting version, original exception type) carried via JSON-RPC error code -32050. 2. CLI-side: tiered output — emit a yellow pre-flight warning on detected CLI/SDK skew; render only the safe summary + remediation hint by default; reveal the full .NET diagnostic payload under --debug; always log the full payload via LogDebug. Also fault the BackchannelCompletionSource immediately on codegen failure so users no longer wait through the 60s timeout. 3. CLI-side: prune leftover cli.sock.* files older than 24 hours from ~/.aspire/cli/runtime/sockets/ on startup so stale entries don't accumulate from previous crashed runs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Drop [JsonPropertyName(camelCase)] from CLI diagnostic DTO so the source-generated context deserializes the server's default PascalCase payload. Add a wire-contract test that round-trips the on-the-wire shape and the BackchannelJsonSerializerContext options. - Use SemVersion.ComparePrecedence in IsKnownIncompatibleSkew so SemVer prerelease identifiers are compared (the #16709 case: 13.4.0-preview.1.26218.1 vs 13.4.0-preview.1.26227.1). Update skew tests to cover prerelease and build-metadata cases. - Resolve the runtime Aspire.Hosting version by walking AppDomain.CurrentDomain.GetAssemblies(); never fall back to Aspire.Hosting.RemoteHost (which is what typeof(AssemblyLoader) returned). Add a regression test. - Only the diagnostic-section header keeps the microscope emoji; the continuation lines (Exception, Type, Member, runtime version, loaded assemblies) render as plain text indented under the header. - Tests: use Directory.CreateTempSubdirectory() instead of manually combining Path.GetTempPath() + Guid for CliPathHelper janitor tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Catch AppHostCodeGenerationException in sdk dump per-integration path so one failing integration does not abort the full Task.WhenAll batch. - Log the full serialized AppHostCodeGenerationDiagnostic payload in RenderCodeGenerationFailure so debug logs match the XML doc contract. Co-authored-by: Copilot <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 -- 17556Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17556" |
|
❓ CLI E2E Tests unknown — 107 passed, 0 failed, 2 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #26534110239 |
Documents the new actionable diagnostics introduced for version-skew TypeLoadException failures in TypeScript AppHost operations (aspire add, aspire restore, aspire run). Users now see an explicit error message directing them to run 'aspire update' when the CLI and SDK versions are incompatible, instead of an opaque timeout or TypeLoadException. Relates to microsoft/aspire#17556 (backport of #17262 to release/13.4). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Pull request created: #1103
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#1103 targeting Updated Note This draft PR needs human review before merging. |
#1103) * docs: add TypeScript AppHost CLI/SDK version mismatch troubleshooting Documents the new actionable diagnostics introduced for version-skew TypeLoadException failures in TypeScript AppHost operations (aspire add, aspire restore, aspire run). Users now see an explicit error message directing them to run 'aspire update' when the CLI and SDK versions are incompatible, instead of an opaque timeout or TypeLoadException. Relates to microsoft/aspire#17556 (backport of #17262 to release/13.4). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address review feedback (1 thread) - Clarify the SDK-newer-than-CLI update flow and rerun step (PRRT_kwDOQK_VN86FPN8J) Verified against microsoft/aspire@11bea2e on branch release/13.4. Edited per the doc-writer skill. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: aspire-repo-bot[bot] <268009190+aspire-repo-bot[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: David Pine <7679720+IEvangelist@users.noreply.github.com>
Backport of #17262 to release/13.4
/cc @IEvangelist
Customer Impact
TypeScript AppHost operations (
aspire add,aspire restore,aspire run/start) can fail with opaqueTypeLoadExceptionand startup timeouts when the CLI/runtime and restored SDK assemblies are incompatible (including 13.3.0-pinned projects run with a 13.4 CLI). This backport adds actionable diagnostics and immediate failure behavior instead of opaque timeout paths, reducing customer dead-ends and triage time.Testing
Risk
Low. The change is primarily additive and focused on failure-path diagnostics/error handling (plus stale socket cleanup guardrails and a sdk-dump catch-path fix). Normal successful AppHost startup/codegen paths are not intentionally changed, and coverage was added around the new behavior.
Regression?
Yes. This addresses #16959 (explicitly tagged
‼️regression-from-last-release) and #16709, where TypeScript AppHost scenarios regressed intoTypeLoadExceptionfailures under version-skew/binary-mismatch conditions.