Skip to content

Add VS Code Go debugging support#17406

Open
davidfowl wants to merge 2 commits into
mainfrom
codex/vscode-go-debugging
Open

Add VS Code Go debugging support#17406
davidfowl wants to merge 2 commits into
mainfrom
codex/vscode-go-debugging

Conversation

@davidfowl
Copy link
Copy Markdown
Contributor

@davidfowl davidfowl commented May 23, 2026

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 the golang.go debugger using dlv-dap.

Implementation summary:

  • Adds Go debugger capability detection for golang.go in the VS Code extension.
  • Maps Aspire Go launch configurations to VS Code Go debug configurations, including program, cwd, args, and Delve buildFlags.
  • Emits Go launch metadata from Aspire.Hosting.Go and strips Go tool/build arguments in IDE debug mode so only app args reach the debugged program.
  • Keeps WithDelveServer as the explicit process-owned headless Delve path by removing the IDE debug support annotation when Delve owns the resource command.
  • Adds a Go debugging playground for manual VS Code validation.

User-facing usage

Go resources can be debugged from the Aspire VS Code extension when the Go extension is installed:

#pragma warning disable ASPIREGO001

var builder = DistributedApplication.CreateBuilder(args);

builder.AddGoApp("api", "../api", buildTags: ["playground"])
       .WithAppArgs("--message", "hello-from-aspire")
       .WithHttpEndpoint(env: "PORT")
       .WithExternalHttpEndpoints();

builder.Build().Run();

The playground can be used to verify the full VS Code flow:

  1. Start Run Extension (Go debugging playground) from the Aspire repo.
  2. In the Extension Development Host, start Debug Go Debugging AppHost.
  3. Set a breakpoint in playground/GoDebugging/api/main.go.

The Go API uses the playground build tag and receives --message hello-from-aspire as 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-tests
  • npm run lint
  • npm 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:minimal
  • MSBUILDTERMINALLOGGER=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:minimal
  • dotnet 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 Detailed
  • Manual VS Code Extension Development Host verification of the Go debugging playground, including breakpoint/debug launch behavior.

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
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

@davidfowl davidfowl requested a review from adamint as a code owner May 23, 2026 03:50
Copilot AI review requested due to automatic review settings May 23, 2026 03:50
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 23, 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 -- 17406

Or

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

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

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 when golang.go is installed, and GoLaunchConfiguration type.
  • Aspire.Hosting.Go: GoLaunchConfiguration.BuildFlags, package-path-aware program path, and IDE-mode arg stripping.
  • WithDelveServer removes any existing SupportsDebuggingAnnotation to 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

@github-actions
Copy link
Copy Markdown
Contributor

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.
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.

Matched test failure patterns (1 test)
  • Aspire.Cli.EndToEnd.Tests.KubernetesDeployWithMySqlTests.DeployK8sWithMySql — Unable to access container registry during publish

@davidfowl davidfowl force-pushed the codex/vscode-go-debugging branch from 411e352 to bdcb598 Compare May 23, 2026 05:21
@davidfowl davidfowl force-pushed the codex/vscode-go-debugging branch from bdcb598 to b9213af Compare May 23, 2026 05:24
@github-actions
Copy link
Copy Markdown
Contributor

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

CLI E2E Tests unknown — 96 passed, 0 failed, 5 unknown (commit b9213af)

View all recordings
Status Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View recording
AddPackageWhileAppHostRunningDetached ▶️ View recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View recording
AgentInitCommand_DefaultSelection_InstallsDefaultSkills ▶️ View recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View recording
AgentMcpListStructuredLogsFromStarterAppCore ▶️ View recording
AllPublishMethodsBuildDockerImages ▶️ View recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View recording
AspireInitSingleFileAppHostRunsViaDotnetRunAppHost ▶️ View recording
AspireInitWithExistingAppHostDirRecreatesMissingNuGetConfigAndPreservesFiles ▶️ View recording
AspireInitWithSolutionFileGeneratesAppHostThatBuildsAgainstChannelHive ▶️ View recording
AspireStartUpdatesStaleTypeScriptAppHostPath ▶️ View recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View recording
AspireUpdateRemovesOrphanAppHostPackageVersionWhenSdkAlreadyCurrent ▶️ 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
DashboardRunWithAgentMcpCore ▶️ View recording
DashboardRunWithOtelTracesReturnsNoTracesCore ▶️ View recording
DeployK8sBasicApiService ▶️ View recording
DeployK8sWithExternalHelmChart ▶️ View recording
DeployK8sWithGarnet ▶️ View recording
DeployK8sWithMongoDB ▶️ View recording
DeployK8sWithMySql ▶️ View recording
DeployK8sWithPostgres ▶️ View recording
DeployK8sWithRabbitMQ ▶️ View recording
DeployK8sWithRedis ▶️ View recording
DeployK8sWithSqlServer ▶️ View recording
DeployK8sWithValkey ▶️ View recording
DeployTypeScriptAppToKubernetes ▶️ 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
GeneratedAspireDevScript_StartsWatchMode_WithConfiguredToolchain ▶️ 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
JavaScriptHostingApisRunFromTypeScriptAppHost ▶️ View recording
LatestCliCanStartStableChannelAppHost ▶️ View recording
LatestCliCanStartStableChannelTypeScriptAppHost ▶️ View recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View recording
LogLevelTrace_ProducesTraceEntriesInCliLogFile ▶️ View recording
LogsCommandShowsResourceLogs ▶️ View recording
OtelLogsReturnsStructuredLogsFromStarterApp ▶️ View recording
OtelLogsReturnsStructuredLogsFromStarterAppIsolated ▶️ View recording
PsCommandListsRunningAppHost ▶️ View recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View recording
PublishJavaScriptPatternsGeneratesExpectedDockerComposeArtifacts ▶️ View recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View recording
ResourceCommand_FailedExecution_DisplaysAppHostLogPathAndLogContainsEntries ▶️ View recording
ResourceCommand_FailsWhenInteractionServiceIsRequired ▶️ View recording
ResourceCommand_SetAndDeleteParameterUpdatesDescribeOutput ▶️ View recording
RestoreGeneratesSdkFiles ▶️ View recording
RestoreGeneratesSdkFiles_WithConfiguredToolchain ▶️ View recording
RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View recording
RunPublishFailureScenarioAsync ▶️ View recording
RunReportsSyntaxErrorsForDotNetAppHost ▶️ View recording
RunReportsSyntaxErrorsForTypeScriptAppHost ▶️ View recording
SecretCrudOnDotNetAppHost ▶️ View recording
SecretCrudOnTypeScriptAppHost ▶️ View recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View recording
StartReportsSyntaxErrorsForDotNetAppHost ▶️ View recording
StartReportsSyntaxErrorsForTypeScriptAppHost ▶️ View recording
StopAllAppHostsFromAppHostDirectory ▶️ View recording
StopJavaPolyglotAppHostUsingApphostDirectory ▶️ View recording
StopNonInteractiveSingleAppHost ▶️ View recording
StopTypeScriptPolyglotAppHostUsingApphostDirectory ▶️ View recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View recording
UpdateProjectChannelToStable_TypeScript_PicksUpStablePackages ▶️ View recording

📹 Recordings uploaded automatically from CI run #26324542070

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.

2 participants