Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ private XDocument CreateProjectFile(IEnumerable<IntegrationReference> integratio
public async Task<AppHostServerPrepareResult> PrepareAsync(
string sdkVersion,
IEnumerable<IntegrationReference> integrations,
CancellationToken cancellationToken = default)
CancellationToken cancellationToken = default,
string? packageSourceOverride = null)
{
var (_, channelName) = await CreateProjectFilesAsync(integrations, cancellationToken);
var (buildSuccess, buildOutput) = await BuildAsync(cancellationToken);
Expand Down
4 changes: 3 additions & 1 deletion src/Aspire.Cli/Projects/IAppHostServerProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ internal interface IAppHostServerProject
/// <param name="sdkVersion">The Aspire SDK version to use.</param>
/// <param name="integrations">The integration references (NuGet packages and/or project references) required by the app host.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <param name="packageSourceOverride">Optional package source to prefer for Aspire package restore.</param>
/// <returns>The preparation result indicating success/failure and any output.</returns>
Task<AppHostServerPrepareResult> PrepareAsync(
string sdkVersion,
IEnumerable<IntegrationReference> integrations,
CancellationToken cancellationToken = default);
CancellationToken cancellationToken = default,
string? packageSourceOverride = null);

/// <summary>
/// Runs the AppHost server process.
Expand Down
242 changes: 214 additions & 28 deletions src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/Aspire.Cli/Scaffolding/IScaffoldingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ namespace Aspire.Cli.Scaffolding;
/// <param name="ProjectName">Optional project name.</param>
/// <param name="SdkVersion">Optional Aspire SDK version to use for scaffolding.</param>
/// <param name="Channel">Optional Aspire channel to use for scaffolding.</param>
/// <param name="PackageSourceOverride">Optional package source to prefer when restoring scaffold/code-generation packages.</param>
internal record ScaffoldContext(
LanguageInfo Language,
DirectoryInfo TargetDirectory,
string? ProjectName = null,
string? SdkVersion = null,
string? Channel = null);
string? Channel = null,
string? PackageSourceOverride = null);

/// <summary>
/// Service for scaffolding new AppHost projects.
Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Cli/Scaffolding/ScaffoldingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private async Task<bool> ScaffoldGuestLanguageAsync(ScaffoldContext context, Can

var prepareResult = await _interactionService.ShowStatusAsync(
"Preparing Aspire server...",
() => appHostServerProject.PrepareAsync(prepareSdkVersion, integrations, cancellationToken),
() => appHostServerProject.PrepareAsync(prepareSdkVersion, integrations, cancellationToken, packageSourceOverride: context.PackageSourceOverride),
emoji: KnownEmojis.Gear);
if (!prepareResult.Success)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ private async Task<TemplateResult> ApplyEmptyAppHostTemplateAsync(CallbackTempla
new DirectoryInfo(outputPath),
projectName,
SdkVersion: inputs.Version,
Channel: inputs.Channel);
Channel: inputs.Channel,
PackageSourceOverride: inputs.Source);
if (!await _scaffoldingService.ScaffoldAsync(context, cancellationToken))
{
return new TemplateResult((int)CliExitCodes.FailedToCreateNewProject);
Expand Down
3 changes: 2 additions & 1 deletion tests/Aspire.Cli.Tests/Projects/AppHostServerSessionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ private sealed class RecordingAppHostServerProject : IAppHostServerProject
public Task<AppHostServerPrepareResult> PrepareAsync(
string sdkVersion,
IEnumerable<IntegrationReference> integrations,
CancellationToken cancellationToken = default) =>
CancellationToken cancellationToken = default,
string? packageSourceOverride = null) =>
throw new NotSupportedException();

public (string SocketPath, Process Process, OutputCollector OutputCollector) Run(
Expand Down
Loading
Loading