Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 14 additions & 11 deletions src/Aspire.Cli/Commands/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,32 @@ protected override async Task<int> ExecuteAsync(ParseResult parseResult, Cancell
return ExitCodeConstants.FailedToTrustCertificates;
}

appHostCompatabilityCheck = await AppHostHelper.CheckAppHostCompatabilityAsync(_runner, effectiveAppHostProjectFile, cancellationToken);
var watch = parseResult.GetValue<bool>("--watch");

if (!appHostCompatabilityCheck?.IsCompatableAppHost ?? throw new InvalidOperationException("IsCompatableAppHost is null"))
if (!watch)
{
return ExitCodeConstants.FailedToDotnetRunAppHost;
}

var watch = parseResult.GetValue<bool>("--watch");
var buildExitCode = await AppHostHelper.BuildAppHostAsync(_runner, effectiveAppHostProjectFile, cancellationToken);

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;
}
}

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

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

var backchannelCompletitionSource = new TaskCompletionSource<AppHostBackchannel>();

var pendingRun = _runner.RunAsync(
effectiveAppHostProjectFile,
watch,
true,
!watch,
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