Skip to content

dont't prompt for version when --version was supplied#15527

Open
Muckenbatscher wants to merge 4 commits intomicrosoft:mainfrom
Muckenbatscher:add-version-no-prompt
Open

dont't prompt for version when --version was supplied#15527
Muckenbatscher wants to merge 4 commits intomicrosoft:mainfrom
Muckenbatscher:add-version-no-prompt

Conversation

@Muckenbatscher
Copy link
Contributor

Description

When the --version flag is supplied to aspire CLI during aspire add it would previously prompt for the version anyways.
This only happened when the supplied version is not the latest version of the selected integration package.

Now the CLI will search for all existing versions of a package and if a match to the supplied version is found, it will add it to the Apphost without prompting.
If the supplied version is not found in any of the channels the CLI will still prompt for a version bt will suggest the latest version from each of the sources.

The search for nuget versions is done with the dotnet CLI using the --exact-match flag. This will make sure that all the versions that are returned are from the same package.
The search results are cached like before. For this the key was extended to include the "exactMatch" parameter.
(This means that previously cached pacakage searches cause a cache miss now, because they wil generate a different key)

Fixes #15396
Reverts the workaround PR #15393

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

…pire add

The interactive flow would be initiated when a package was found but the version passed by the --version flag is not the latest version of the integration nuget package.
Now fetch all the versions for the selected package from all configured channels.
If the CLI supplied version is found in the list of the available versions skip the interactive flow and use the CLI supplied version.
When supplying a version parameter through the CLI handle the cases:
* supplied version is not the latest version found in any channel
* supplied version does not exist in any of the channels
@github-actions
Copy link
Contributor

github-actions bot commented Mar 24, 2026

🚀 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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15527

Or

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

@Muckenbatscher
Copy link
Contributor Author

I felt responsible for a fix because the CPM test that I introduced surfaced the behaviour and caused the CLI E2E tests to fail😀

@Muckenbatscher
Copy link
Contributor Author

Muckenbatscher commented Mar 24, 2026

Also just noticed something:
Various testclasses use a TestDotnetCliRunner. For those I had to adjust the SearchPackagesAsyncCallback to take the new parameter exactMatch.
It seems like in the process of doing so I introduced unrelated changes from automatically applying Code Cleanup on Save in Visual Studio. This mostly includes applying the .editorconfig for whitespaces and sorting usings from what I can tell.

Would you prefer for me to alter the affecting commit to not include these changes?
So the actual changes are not polluted?

`aspire add redis --version 13.1.2` will not prompt for a version in this E2E CLI test
@Muckenbatscher Muckenbatscher force-pushed the add-version-no-prompt branch from b53e647 to 84b964f Compare March 24, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aspire add --version should not prompt for a version

1 participant