Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/Aspire.Cli/Commands/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,23 @@ protected override async Task<int> ExecuteAsync(ParseResult parseResult, Cancell

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

var buildExitCode = await AppHostHelper.BuildAppHostAsync(_runner, effectiveAppHostProjectFile, cancellationToken);

if (buildExitCode != 0)
if (!watch)
{
AnsiConsole.MarkupLine($"[red bold]:thumbs_down: The project could not be built. For more information run with --debug switch.[/]");
return ExitCodeConstants.FailedToBuildArtifacts;
var buildExitCode = await AppHostHelper.BuildAppHostAsync(_runner, effectiveAppHostProjectFile, cancellationToken);

if (buildExitCode != 0)
{
AnsiConsole.MarkupLine($"[red bold]:thumbs_down: The project could not be built. For more information run with --debug switch.[/]");
return ExitCodeConstants.FailedToBuildArtifacts;
}
}

var backchannelCompletitionSource = new TaskCompletionSource<AppHostBackchannel>();

var pendingRun = _runner.RunAsync(
effectiveAppHostProjectFile,
watch,
true,
!watch, // If we aren't in watch mode we can no-build here, but watch doesn't support no-build.
Array.Empty<string>(),
env,
backchannelCompletitionSource,
Expand Down
4 changes: 3 additions & 1 deletion src/Aspire.Cli/DotNetCliRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ public async Task<int> RunAsync(FileInfo projectFile, bool watch, bool noBuild,

if (watch && noBuild)
{
throw new InvalidOperationException("Cannot use --watch and --no-build at the same time.");
var ex = new InvalidOperationException("Cannot use --watch and --no-build at the same time.");
backchannelCompletionSource?.SetException(ex);
throw ex;
}

var watchOrRunCommand = watch ? "watch" : "run";
Expand Down
Loading