Skip to content
Merged
8 changes: 1 addition & 7 deletions src/Aspire.Cli/Commands/AddCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ public AddCommand(IDotNetCliRunner runner, INuGetPackageCache nuGetPackageCache,
versionOption.Description = "The version of the integration to add.";
Options.Add(versionOption);

var prereleaseOption = new Option<bool>("--prerelease");
prereleaseOption.Description = "Include pre-release versions of the integration when searching.";
Options.Add(prereleaseOption);

var sourceOption = new Option<string?>("--source", "-s");
sourceOption.Description = "The NuGet source to use for the integration.";
Options.Add(sourceOption);
Expand All @@ -79,13 +75,11 @@ protected override async Task<int> ExecuteAsync(ParseResult parseResult, Cancell
return ExitCodeConstants.FailedToFindProject;
}

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

var source = parseResult.GetValue<string?>("--source");

var packages = await _interactionService.ShowStatusAsync(
"Searching for Aspire packages...",
() => _nuGetPackageCache.GetIntegrationPackagesAsync(effectiveAppHostProjectFile.Directory!, prerelease, source, cancellationToken)
() => _nuGetPackageCache.GetIntegrationPackagesAsync(effectiveAppHostProjectFile.Directory!, true, source, cancellationToken)
Comment thread
davidfowl marked this conversation as resolved.
Outdated
);

var version = parseResult.GetValue<string?>("--version");
Expand Down
7 changes: 1 addition & 6 deletions src/Aspire.Cli/Commands/NewCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ public NewCommand(IDotNetCliRunner runner, INuGetPackageCache nuGetPackageCache,
var templateVersionOption = new Option<string?>("--version", "-v");
templateVersionOption.Description = "The version of the project templates to use.";
Options.Add(templateVersionOption);

var prereleaseOption = new Option<bool>("--prerelease");
prereleaseOption.Description = "Include prerelease versions when searching for project templates.";
Options.Add(prereleaseOption);
}

private async Task<(string TemplateName, string TemplateDescription, Func<string, string> PathDeriver)> GetProjectTemplateAsync(ParseResult parseResult, CancellationToken cancellationToken)
Expand Down Expand Up @@ -141,9 +137,8 @@ protected override async Task<int> ExecuteAsync(ParseResult parseResult, Cancell
var template = await GetProjectTemplateAsync(parseResult, cancellationToken);
var name = await GetProjectNameAsync(parseResult, cancellationToken);
var outputPath = await GetOutputPathAsync(parseResult, template.PathDeriver, name, cancellationToken);
var prerelease = parseResult.GetValue<bool>("--prerelease");
var source = parseResult.GetValue<string?>("--source");
var version = await GetProjectTemplatesVersionAsync(parseResult, prerelease, source, cancellationToken);
var version = await GetProjectTemplatesVersionAsync(parseResult, true, source, cancellationToken);
Comment thread
mitchdenny marked this conversation as resolved.
Outdated

var templateInstallCollector = new OutputCollector();
var templateInstallResult = await _interactionService.ShowStatusAsync<(int ExitCode, string? TemplateVersion)>(
Expand Down
6 changes: 4 additions & 2 deletions src/Aspire.Cli/DotNetCliRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal interface IDotNetCliRunner
Task<int> NewProjectAsync(string templateName, string name, string outputPath, DotNetCliRunnerInvocationOptions options, CancellationToken cancellationToken);
Task<int> BuildAsync(FileInfo projectFilePath, DotNetCliRunnerInvocationOptions options, CancellationToken cancellationToken);
Task<int> AddPackageAsync(FileInfo projectFilePath, string packageName, string packageVersion, DotNetCliRunnerInvocationOptions options, CancellationToken cancellationToken);
Task<(int ExitCode, NuGetPackage[]? Packages)> SearchPackagesAsync(DirectoryInfo workingDirectory, string query, bool prerelease, int take, int skip, string? nugetSource, DotNetCliRunnerInvocationOptions options, CancellationToken cancellationToken);
Task<(int ExitCode, NuGetPackage[]? Packages)> SearchPackagesAsync(DirectoryInfo workingDirectory, string query, bool prerelease, int take, int skip, string? nugetSource, DotNetCliRunnerInvocationOptions? options, CancellationToken cancellationToken);
}

internal sealed class DotNetCliRunnerInvocationOptions
Expand Down Expand Up @@ -589,9 +589,11 @@ public async Task<int> AddPackageAsync(FileInfo projectFilePath, string packageN
return result;
}

public async Task<(int ExitCode, NuGetPackage[]? Packages)> SearchPackagesAsync(DirectoryInfo workingDirectory, string query, bool prerelease, int take, int skip, string? nugetSource, DotNetCliRunnerInvocationOptions options, CancellationToken cancellationToken)
public async Task<(int ExitCode, NuGetPackage[]? Packages)> SearchPackagesAsync(DirectoryInfo workingDirectory, string query, bool prerelease, int take, int skip, string? nugetSource, DotNetCliRunnerInvocationOptions? options, CancellationToken cancellationToken)
Comment thread
mitchdenny marked this conversation as resolved.
Outdated
{
using var activity = _activitySource.StartActivity();

Comment thread
davidfowl marked this conversation as resolved.
Outdated
options ??= new DotNetCliRunnerInvocationOptions();

List<string> cliArgs = [
"package",
Expand Down
6 changes: 3 additions & 3 deletions tests/Aspire.Cli.Tests/TestServices/TestDotNetCliRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal sealed class TestDotNetCliRunner : IDotNetCliRunner
public Func<string, string, string?, bool, DotNetCliRunnerInvocationOptions, CancellationToken, (int ExitCode, string? TemplateVersion)>? InstallTemplateAsyncCallback { get; set; }
public Func<string, string, string, DotNetCliRunnerInvocationOptions, CancellationToken, int>? NewProjectAsyncCallback { get; set; }
public Func<FileInfo, bool, bool, string[], IDictionary<string, string>?, TaskCompletionSource<IAppHostBackchannel>?, DotNetCliRunnerInvocationOptions, CancellationToken, Task<int>>? RunAsyncCallback { get; set; }
public Func<DirectoryInfo, string, bool, int, int, string?, DotNetCliRunnerInvocationOptions, CancellationToken, (int ExitCode, NuGetPackage[]? Packages)>? SearchPackagesAsyncCallback { get; set; }
public Func<DirectoryInfo, string, bool, int, int, string?, DotNetCliRunnerInvocationOptions?, CancellationToken, (int ExitCode, NuGetPackage[]? Packages)>? SearchPackagesAsyncCallback { get; set; }
public Func<DotNetCliRunnerInvocationOptions, CancellationToken, int>? TrustHttpCertificateAsyncCallback { get; set; }

public Task<int> AddPackageAsync(FileInfo projectFilePath, string packageName, string packageVersion, DotNetCliRunnerInvocationOptions options, CancellationToken cancellationToken)
Expand Down Expand Up @@ -78,10 +78,10 @@ public Task<int> RunAsync(FileInfo projectFile, bool watch, bool noBuild, string
: throw new NotImplementedException();
}

public Task<(int ExitCode, NuGetPackage[]? Packages)> SearchPackagesAsync(DirectoryInfo workingDirectory, string query, bool prerelease, int take, int skip, string? nugetSource, DotNetCliRunnerInvocationOptions options, CancellationToken cancellationToken)
public Task<(int ExitCode, NuGetPackage[]? Packages)> SearchPackagesAsync(DirectoryInfo workingDirectory, string query, bool prerelease, int take, int skip, string? nugetSource, DotNetCliRunnerInvocationOptions? options, CancellationToken cancellationToken)
{
return SearchPackagesAsyncCallback != null
? Task.FromResult(SearchPackagesAsyncCallback(workingDirectory, query, prerelease, take, skip, nugetSource, options, cancellationToken))
? Task.FromResult(SearchPackagesAsyncCallback(workingDirectory, query, prerelease, take, skip, nugetSource, options ?? new DotNetCliRunnerInvocationOptions(), cancellationToken))
: throw new NotImplementedException();
}

Expand Down