Skip version prompt when --version is explicitly specified#16024
Skip version prompt when --version is explicitly specified#16024mitchdenny wants to merge 1 commit intomainfrom
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16024Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16024" |
There was a problem hiding this comment.
Pull request overview
Fixes a CLI usability/CI reliability issue where aspire add <integration> --version <ver> could fall into an interactive version-selection prompt when the requested version isn’t present in NuGet search results, instead of passing the explicit version through to dotnet add package --version.
Changes:
- Update
AddCommandpackage-selection flow to skip the version prompt when--versionis explicitly provided and always pass that version through to the add operation. - Add unit tests covering “explicit version not in search results” for both single-package and multi-package match scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Aspire.Cli/Commands/AddCommand.cs | Skips version prompting when --version is provided and uses the CLI-specified version for the add operation. |
| tests/Aspire.Cli.Tests/Commands/AddCommandTests.cs | Adds tests ensuring no version prompt occurs when an explicit version is provided but not found in search results. |
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
3461440 to
fc09d80
Compare
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
|
What happens if a version is specified that doesn't exist? |
fc09d80 to
0538f14
Compare
When 'aspire add --version <ver>' is used, skip the interactive version prompt entirely and pass the specified version directly to 'dotnet add package --version'. If the version doesn't exist, the dotnet add command will fail naturally with proper NuGet context. Previously, if the specified version wasn't found in the NuGet search results, the CLI would fall into the interactive flow and prompt the user for a version, breaking non-interactive/CI scenarios. Fixes #15396 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0538f14 to
ba5b813
Compare
|
🎬 CLI E2E Test Recordings — 56 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #24227236753 |
This is what it looks like presently: https://asciinema.org/a/ukUigAtJuG9R3dPB It's pretty ugly, but at the same time when something like this does go wrong and you don't want to offer an interactive picker the diagnostic information is useful. However it is a lot of .NET-ism to drop on people too. |
Description
When
aspire add <integration> --version <ver>is used with a version that isn't found in the NuGet search results, the CLI falls into the interactive flow and prompts the user to select a version — even though the version was explicitly specified on the command line. This breaks non-interactive/CI scenarios (e.g., the CPM test).This PR fixes the issue by skipping the version prompt entirely when
--versionis explicitly provided. The specified version is passed directly todotnet add package --version, letting NuGet validate the version in the proper context. If the version doesn't exist, thedotnet addcommand will fail naturally with an appropriate error.Changes
AddCommand.cs: When--versionis specified:count == 1: Skip the interactive flow entirely, take the matched package directly.count > 1: Only prompt for package name disambiguation, skip version prompt.count == 0: Show all packages for name selection, skip version prompt.PackageVersionwith the CLI-specified version.AddCommandTests.cs: Added two new tests:Fixes #15396
Checklist