Skip to content

Commit e703fab

Browse files
committed
Fix --watch hangs. (#8585)
* Fix --watch hangs. * Don't prebuild in watch mode. * Fix up merge.
1 parent 989bb23 commit e703fab

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/Aspire.Cli/Commands/RunCommand.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,30 @@ protected override async Task<int> ExecuteAsync(ParseResult parseResult, Cancell
7676

7777
appHostCompatabilityCheck = await AppHostHelper.CheckAppHostCompatabilityAsync(_runner, effectiveAppHostProjectFile, cancellationToken);
7878

79-
if (!appHostCompatabilityCheck?.IsCompatableAppHost ?? throw new InvalidOperationException("IsCompatableAppHost is null"))
79+
if (!appHostCompatabilityCheck?.IsCompatableAppHost ?? throw new InvalidOperationException("IsCompatibleAppHost is null"))
8080
{
8181
return ExitCodeConstants.FailedToDotnetRunAppHost;
8282
}
8383

8484
var watch = parseResult.GetValue<bool>("--watch");
8585

86-
var buildExitCode = await AppHostHelper.BuildAppHostAsync(_runner, effectiveAppHostProjectFile, cancellationToken);
87-
88-
if (buildExitCode != 0)
86+
if (!watch)
8987
{
90-
AnsiConsole.MarkupLine($"[red bold]:thumbs_down: The project could not be built. For more information run with --debug switch.[/]");
91-
return ExitCodeConstants.FailedToBuildArtifacts;
88+
var buildExitCode = await AppHostHelper.BuildAppHostAsync(_runner, effectiveAppHostProjectFile, cancellationToken);
89+
90+
if (buildExitCode != 0)
91+
{
92+
AnsiConsole.MarkupLine($"[red bold]:thumbs_down: The project could not be built. For more information run with --debug switch.[/]");
93+
return ExitCodeConstants.FailedToBuildArtifacts;
94+
}
9295
}
9396

9497
var backchannelCompletitionSource = new TaskCompletionSource<AppHostBackchannel>();
9598

9699
var pendingRun = _runner.RunAsync(
97100
effectiveAppHostProjectFile,
98101
watch,
99-
true,
102+
!watch,
100103
Array.Empty<string>(),
101104
env,
102105
backchannelCompletitionSource,

src/Aspire.Cli/Utils/AppHostHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal static class AppHostHelper
1111
{
1212
private static readonly ActivitySource s_activitySource = new ActivitySource(nameof(AppHostHelper));
1313

14-
internal static async Task<(bool IsCompatableAppHost, bool SupportsBackchannel, string? AspireHostingSdkVersion)> CheckAppHostCompatabilityAsync(DotNetCliRunner runner, FileInfo projectFile, CancellationToken cancellationToken)
14+
internal static async Task<(bool IsCompatibleAppHost, bool SupportsBackchannel, string? AspireHostingSdkVersion)> CheckAppHostCompatabilityAsync(DotNetCliRunner runner, FileInfo projectFile, CancellationToken cancellationToken)
1515
{
1616
var appHostInformation = await GetAppHostInformationAsync(runner, projectFile, cancellationToken);
1717

0 commit comments

Comments
 (0)