Skip to content

Commit 124aab1

Browse files
committed
More fixes
1 parent d9e2ac5 commit 124aab1

2 files changed

Lines changed: 12 additions & 29 deletions

File tree

src/Aspire.Cli/Commands/AppHostLauncher.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public async Task<int> LaunchDetachedAsync(
125125
logger.LogDebug("Waiting for socket with prefix: {SocketPrefix}, Hash: {Hash}", expectedSocketPrefix, expectedHash);
126126

127127
// Start the child process and wait for the backchannel
128-
var launchResult = await LaunchAndWaitForBackchannelAsync(executablePath, childArgs, expectedHash, format, cancellationToken);
128+
var launchResult = await LaunchAndWaitForBackchannelAsync(executablePath, childArgs, expectedHash, cancellationToken);
129129

130130
// Handle failure cases
131131
if (launchResult.Backchannel is null || launchResult.ChildProcess is null)
@@ -212,7 +212,6 @@ private async Task<LaunchResult> LaunchAndWaitForBackchannelAsync(
212212
string executablePath,
213213
List<string> childArgs,
214214
string expectedHash,
215-
OutputFormat? format,
216215
CancellationToken cancellationToken)
217216
{
218217
Process? childProcess = null;
@@ -272,17 +271,9 @@ private async Task<LaunchResult> LaunchAndWaitForBackchannelAsync(
272271
return null;
273272
}
274273

275-
IAppHostAuxiliaryBackchannel? backchannel;
276-
if (format == OutputFormat.Json)
277-
{
278-
backchannel = await WaitForBackchannelAsync();
279-
}
280-
else
281-
{
282-
backchannel = await interactionService.ShowStatusAsync(
283-
RunCommandStrings.StartingAppHostInBackground,
284-
WaitForBackchannelAsync);
285-
}
274+
var backchannel = await interactionService.ShowStatusAsync(
275+
RunCommandStrings.StartingAppHostInBackground,
276+
WaitForBackchannelAsync);
286277

287278
return new LaunchResult(childProcess, backchannel, childExitedEarly, childExitCode);
288279
}

src/Aspire.Cli/Commands/PsCommand.cs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,27 +79,19 @@ protected override async Task<int> ExecuteAsync(ParseResult parseResult, Cancell
7979

8080
// Scan for running AppHosts (same as ListAppHostsTool)
8181
// Skip status display for JSON output to avoid contaminating stdout
82-
List<IAppHostAuxiliaryBackchannel> connections;
83-
if (format == OutputFormat.Json)
84-
{
85-
await _backchannelMonitor.ScanAsync(cancellationToken).ConfigureAwait(false);
86-
connections = _backchannelMonitor.Connections.ToList();
87-
}
88-
else
89-
{
90-
connections = await _interactionService.ShowStatusAsync(
91-
SharedCommandStrings.ScanningForRunningAppHosts,
92-
async () =>
93-
{
94-
await _backchannelMonitor.ScanAsync(cancellationToken).ConfigureAwait(false);
95-
return _backchannelMonitor.Connections.ToList();
96-
});
97-
}
82+
var connections = await _interactionService.ShowStatusAsync(
83+
SharedCommandStrings.ScanningForRunningAppHosts,
84+
async () =>
85+
{
86+
await _backchannelMonitor.ScanAsync(cancellationToken).ConfigureAwait(false);
87+
return _backchannelMonitor.Connections.ToList();
88+
});
9889

9990
if (connections.Count == 0)
10091
{
10192
if (format == OutputFormat.Json)
10293
{
94+
// Structured output always goes to stdout.
10395
_interactionService.DisplayRawText("[]", ConsoleOutput.Standard);
10496
}
10597
else

0 commit comments

Comments
 (0)