Add VS Code Go debugging support#17406
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17406Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17406" |
There was a problem hiding this comment.
Pull request overview
Adds Go debugging support to the Aspire VS Code extension by mapping Aspire Go launch configurations to the golang.go extension's dlv-dap debug adapter. On the hosting side, WithVSCodeDebugging now emits package/working-directory/build-flag metadata and strips the go run [...flags] <pkg> prefix from runtime args (since the VS Code Go debugger owns build/launch), while WithDelveServer removes the VS Code debugging annotation so DCP doesn't hand it to the IDE.
Changes:
- VS Code extension: new
goDebuggerExtension, capability advertisement whengolang.gois installed, andGoLaunchConfigurationtype. - Aspire.Hosting.Go:
GoLaunchConfiguration.BuildFlags, package-path-aware program path, and IDE-mode arg stripping. WithDelveServerremoves any existingSupportsDebuggingAnnotationto avoid conflicting with the headless Delve flow.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Hosting.Go/GoLaunchConfiguration.cs | Adds build_flags field to the launch configuration. |
| src/Aspire.Hosting.Go/GoHostingExtensions.cs | Resolves package/working dir/build flags at launch time and strips go run prefix in IDE mode; clears debugging annotation in WithDelveServer. |
| extension/src/dcp/types.ts | Adds GoLaunchConfiguration type and type guard. |
| extension/src/capabilities.ts | Advertises go / golang.go capabilities when extension installed. |
| extension/src/debugger/languages/go.ts | New Go debugger extension targeting dlv-dap. |
| extension/src/debugger/debuggerExtensions.ts | Registers Go debugger extension conditionally. |
| extension/src/loc/strings.ts, package.nls.json | New Go / Go: {0} localization strings. |
| extension/src/test/goDebugger.test.ts | Unit tests for capability and Go debugger configuration. |
| tests/Aspire.Hosting.Go.Tests/AddGoAppTests.cs | Tests for delve annotation removal, launch config, build flags, and arg stripping. |
Copilot's findings
- Files reviewed: 10/10 changed files
- Comments generated: 0
|
Re-running the failed jobs in the CI workflow for this pull request because 3 jobs were identified as retry-safe transient failures in the CI run attempt.
Matched test failure patterns (1 test)
|
411e352 to
bdcb598
Compare
bdcb598 to
b9213af
Compare
|
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.
|
|
❓ CLI E2E Tests unknown — 96 passed, 0 failed, 5 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #26324542070 |
Description
This adds native VS Code debugging support for Aspire Go resources. Previously the Go integration could start a headless Delve server with
WithDelveServer, but that path was process-owned and required an IDE attach workflow. With this change, the AppHost can emit Go launch metadata and the VS Code extension maps it to thegolang.godebugger usingdlv-dap.Implementation summary:
golang.goin the VS Code extension.program,cwd,args, and DelvebuildFlags.Aspire.Hosting.Goand strips Go tool/build arguments in IDE debug mode so only app args reach the debugged program.WithDelveServeras the explicit process-owned headless Delve path by removing the IDE debug support annotation when Delve owns the resource command.User-facing usage
Go resources can be debugged from the Aspire VS Code extension when the Go extension is installed:
The playground can be used to verify the full VS Code flow:
Run Extension (Go debugging playground)from the Aspire repo.Debug Go Debugging AppHost.playground/GoDebugging/api/main.go.The Go API uses the
playgroundbuild tag and receives--message hello-from-aspireas app args. This verifies that Aspire passes Delve build flags to VS Code while stripping Go tool arguments from the debugged program args.Fixes # (issue)
Validation
npm run compile-testsnpm run lintnpm run unit-test -- --grep "Go Debugger"go test -tags playground ./...MSBUILDTERMINALLOGGER=false dotnet build playground/GoDebugging/GoDebugging.AppHost/GoDebugging.AppHost.csproj -m:1 -nr:false -p:BuildInParallel=false -p:UseSharedCompilation=false -v:minimalMSBUILDTERMINALLOGGER=false dotnet build tests/Aspire.Hosting.Go.Tests/Aspire.Hosting.Go.Tests.csproj --no-restore -m:1 -nr:false -p:BuildInParallel=false -p:UseSharedCompilation=false -v:minimaldotnet artifacts/bin/Aspire.Hosting.Go.Tests/Debug/net8.0/Aspire.Hosting.Go.Tests.dll --filter-method "*.WithDelveServer_RemovesVSCodeDebuggingAnnotation" --filter-method "*.WithVSCodeDebugging_PopulatesGoLaunchConfiguration" --filter-method "*.WithVSCodeDebugging_OmitsBuildFlagsWhenNoneConfigured" --filter-method "*.WithVSCodeDebugging_RemovesGoToolArguments" --filter-method "*.WithVSCodeDebugging_DoesNotRemoveGoToolArguments_WhenGoLaunchConfigurationUnsupported" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" --timeout 30s --output DetailedChecklist
<remarks />and<code />elements on your triple slash comments?