Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 31, 2025

This PR addresses an issue in the aspire add command where we show two versions of a package when a channel is chosen when only one should be shown. The underlying reason is that a channel is often comprised of multiple feeds (e.g. the daily feed references dotnet9 and nuget.org) and in the case of the Docker integration there is a pre-release package in both.

This update effectively filters the list so we only show the highest version across package sources.

Before:

image

After:

image

Copilot AI changed the title [WIP] Filter package versions to show highest for each channel Filter to highest package version per channel in aspire add command Oct 31, 2025
Copilot AI requested a review from mitchdenny October 31, 2025 07:44
Copilot finished work on behalf of mitchdenny October 31, 2025 07:44
@mitchdenny
Copy link
Member

/test-scenario deployment-docker

@github-actions
Copy link
Contributor

🤖 AI Agent Task Created

Scenario: deployment-docker

An AI agent has been assigned to execute this scenario.

📝 Issue: https://github.com/dotnet/aspire-playground/issues/84

Please navigate to the issue for more details and to track progress.

@github-actions
Copy link
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12553

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12553"

1 similar comment
@github-actions
Copy link
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12553

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12553"

@mitchdenny mitchdenny marked this pull request as ready for review November 1, 2025 05:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds filtering logic to the Aspire CLI's add command to show only the highest version for each package when prompting users, along with comprehensive test coverage for this new behavior.

Key changes:

  • Modified AddCommandPrompter to filter packages to the highest version per package ID and per channel
  • Added test infrastructure (PromptForSelectionCallback) to capture and inspect selection prompts in tests
  • Added three test cases validating the filtering behavior for different scenarios

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Aspire.Cli/Commands/AddCommand.cs Implements filtering logic in PromptForIntegrationAsync and PromptForIntegrationVersionAsync to show only highest versions per package ID and channel
tests/Aspire.Cli.Tests/TestServices/TestConsoleInteractionService.cs Adds PromptForSelectionCallback property to enable tests to inspect what choices are presented to users
tests/Aspire.Cli.Tests/Commands/AddCommandTests.cs Adds three test cases and a fake NuGet cache implementation to verify version filtering behavior

Comment on lines +691 to +704
private sealed class FakeNuGetPackageCache : Aspire.Cli.NuGet.INuGetPackageCache
{
public Task<IEnumerable<NuGetPackage>> GetTemplatePackagesAsync(DirectoryInfo workingDirectory, bool prerelease, FileInfo? nugetConfigFile, CancellationToken cancellationToken)
=> Task.FromResult<IEnumerable<NuGetPackage>>([]);

public Task<IEnumerable<NuGetPackage>> GetIntegrationPackagesAsync(DirectoryInfo workingDirectory, bool prerelease, FileInfo? nugetConfigFile, CancellationToken cancellationToken)
=> Task.FromResult<IEnumerable<NuGetPackage>>([]);

public Task<IEnumerable<NuGetPackage>> GetCliPackagesAsync(DirectoryInfo workingDirectory, bool prerelease, FileInfo? nugetConfigFile, CancellationToken cancellationToken)
=> Task.FromResult<IEnumerable<NuGetPackage>>([]);

public Task<IEnumerable<NuGetPackage>> GetPackagesAsync(DirectoryInfo workingDirectory, string packageId, Func<string, bool>? filter, bool prerelease, FileInfo? nugetConfigFile, bool useCache, CancellationToken cancellationToken)
=> Task.FromResult<IEnumerable<NuGetPackage>>([]);
}
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FakeNuGetPackageCache class lacks XML documentation. Add a <summary> tag explaining it's a test fake that returns empty package lists for all operations.

Copilot generated this review using guidance from repository custom instructions.

/// <summary>
/// Callback for capturing selection prompts in tests. Uses non-generic IEnumerable and object
/// to work with the generic PromptForSelectionAsync&lt;T&gt; method regardless of T's type.
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed 'PromptForSelectionAsync<T>' to 'PromptForSelectionAsync' - XML documentation should use unescaped angle brackets for generic type parameters in summary tags.

Suggested change
/// to work with the generic PromptForSelectionAsync&lt;T&gt; method regardless of T's type.
/// to work with the generic PromptForSelectionAsync<T> method regardless of T's type.

Copilot uses AI. Check for mistakes.
@davidfowl davidfowl merged commit 572ed6c into main Nov 1, 2025
591 of 597 checks passed
@davidfowl davidfowl deleted the copilot/filter-highest-package-versions branch November 1, 2025 05:44
@dotnet-policy-service dotnet-policy-service bot added this to the 13.1 milestone Nov 1, 2025
@mitchdenny
Copy link
Member

/backport to release/13.0

@github-actions
Copy link
Contributor

github-actions bot commented Nov 1, 2025

Started backporting to release/13.0: https://github.com/dotnet/aspire/actions/runs/18992294037

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants