Skip to content

CLI: Print app host CLI log path when connected to a running app host #17012

@JamesNK

Description

@JamesNK

Description

Follow-up to #17005 which centralized CLI log path display on non-zero exit codes.

When the CLI connects to an already-running app host (e.g., aspire resource, aspire describe, aspire stop, aspire logs, etc.), it should also print the log path of the CLI process managing that app host. This helps users diagnose issues in the managing CLI process, not just the current CLI invocation.

Today, when the child CLI process launches an app host via aspire run, it passes ASPIRE_CLI_PID and ASPIRE_CLI_STARTED as environment variables so the app host knows which CLI process launched it. However, the child CLI's log file path is not communicated, so querying CLI processes (e.g., aspire resource) have no way to surface it.

Proposed Changes

  1. Add ASPIRE_CLI_LOG_FILE environment variable — Add a CliLogFilePath constant to KnownConfigNames. Set it alongside ASPIRE_CLI_PID in DotNetCliRunner, PrebuiltAppHostServer, and DotNetBasedAppHostServerProject when launching the app host.

  2. Add CliLogFilePath to backchannel data types — Add the property to AppHostInformation and GetAppHostInfoResponse in BackchannelDataTypes.cs. Populate it in AuxiliaryBackchannelRpcTarget.GetAppHostInfoAsync() by reading from configuration.

  3. Surface in AppHostConnectionResolver — After resolving a connection, if AppHostInfo.CliLogFilePath is set, store it on CliExecutionContext.AppHostCliLogFilePath (new property).

  4. Display in BaseCommand — In DisplayLogPathOnFailure, if ExecutionContext.AppHostCliLogFilePath is set, print it in addition to the current CLI's log path. May need a new localized string (e.g., SeeAppHostLogsAt) to differentiate.

See CLI logs at XXXX
See AppHost logs at XXXX

Commands That Would Benefit

All commands using AppHostConnectionResolver:

  • aspire resource
  • aspire describe
  • aspire stop
  • aspire logs
  • aspire wait
  • aspire export
  • aspire telemetry logs/spans/traces
  • aspire mcp call/tools

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions