Skip to content

Commit caaa534

Browse files
committed
Add no-cache option to run and publish commands.
1 parent d82adb4 commit caaa534

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/Aspire.Cli/Commands/PublishCommand.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public PublishCommand(IDotNetCliRunner runner, IInteractionService interactionSe
4747
outputPath.Description = "The output path for the generated artifacts.";
4848
outputPath.DefaultValueFactory = (result) => Path.Combine(Environment.CurrentDirectory);
4949
Options.Add(outputPath);
50+
51+
var noCacheOption = new Option<bool>("--no-cache", "-nc");
52+
noCacheOption.Description = "Do not use cached build of the app host.";
53+
Options.Add(noCacheOption);
5054
}
5155

5256
protected override async Task<int> ExecuteAsync(ParseResult parseResult, CancellationToken cancellationToken)
@@ -79,7 +83,8 @@ protected override async Task<int> ExecuteAsync(ParseResult parseResult, Cancell
7983
return ExitCodeConstants.FailedToDotnetRunAppHost;
8084
}
8185

82-
var buildExitCode = await AppHostHelper.BuildAppHostAsync(_appHostBuilder, _interactionService, effectiveAppHostProjectFile, cancellationToken);
86+
var useCache = !parseResult.GetValue<bool>("--no-cache");
87+
var buildExitCode = await AppHostHelper.BuildAppHostAsync(_appHostBuilder, useCache, _interactionService, effectiveAppHostProjectFile, cancellationToken);
8388

8489
if (buildExitCode != 0)
8590
{

src/Aspire.Cli/Commands/RunCommand.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public RunCommand(IDotNetCliRunner runner, IInteractionService interactionServic
4848
var watchOption = new Option<bool>("--watch", "-w");
4949
watchOption.Description = "Start project resources in watch mode.";
5050
Options.Add(watchOption);
51+
52+
var noCacheOption = new Option<bool>("--no-cache", "-nc");
53+
noCacheOption.Description = "Do not use cached build of the app host.";
54+
Options.Add(noCacheOption);
5155
}
5256

5357
protected override async Task<int> ExecuteAsync(ParseResult parseResult, CancellationToken cancellationToken)
@@ -94,7 +98,8 @@ protected override async Task<int> ExecuteAsync(ParseResult parseResult, Cancell
9498

9599
if (!watch)
96100
{
97-
var buildExitCode = await AppHostHelper.BuildAppHostAsync(_appHostBuilder, _interactionService, effectiveAppHostProjectFile, cancellationToken);
101+
var useCache = !parseResult.GetValue<bool>("--no-cache");
102+
var buildExitCode = await AppHostHelper.BuildAppHostAsync(_appHostBuilder, useCache, _interactionService, effectiveAppHostProjectFile, cancellationToken);
98103

99104
if (buildExitCode != 0)
100105
{

src/Aspire.Cli/Utils/AppHostHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ internal static class AppHostHelper
6060
return appHostInformationResult;
6161
}
6262

63-
internal static async Task<int> BuildAppHostAsync(IAppHostBuilder appHostBuilder, IInteractionService interactionService, FileInfo projectFile, CancellationToken cancellationToken)
63+
internal static async Task<int> BuildAppHostAsync(IAppHostBuilder appHostBuilder, bool useCache, IInteractionService interactionService, FileInfo projectFile, CancellationToken cancellationToken)
6464
{
6565
return await interactionService.ShowStatusAsync(
6666
":hammer_and_wrench: Building app host...",
67-
() => appHostBuilder.BuildAppHostAsync(projectFile, true, cancellationToken));
67+
() => appHostBuilder.BuildAppHostAsync(projectFile, useCache, cancellationToken));
6868
}
6969
}

0 commit comments

Comments
 (0)