microsoft/aspire · error · EmptyChoicesException

The requested version

Error message

The requested version '{1}' was not found for package '{0}'.

What it means

In the interactive add flow, when a preferred version is given, AddCommand looks it up in the full version list for the selected package and throws EmptyChoicesException if no package version equals the requested one.

Solutions

  1. Run the command without --version to list available versions and pick a valid one
  2. Check the exact published versions of the package on the feed (nuget.org or your private source)
  3. Correct the version string (typos, wrong channel, pre-release suffix like 9.1.0-preview1)
  4. If using a local/PR hive, ensure the requested version exists in that local package directory

Example fix

// before
aspire add Aspire.Hosting.Redis --version 9.9.0  # not published
// after
aspire add Aspire.Hosting.Redis --version 9.4.0
Defensive patterns

Strategy: validation

Validate before calling

// query available versions before pinning
dotnet package search Aspire.Hosting.Redis --exact-match --versions

Try / catch

try { /* aspire add name --version v */ }
catch (EmptyChoicesException ex) when (ex.Message.Contains("was not found for package"))
{
    // list versions, pick a published one, retry
}

Prevention

When it happens

Trigger: Running 'aspire add <name> --version <v>' where <v> exists in your head but not in the package's published version list (typo, EOL version, or package only published up to a lower version); also hit via GetPackageByInteractiveFlowWithNoMatchesMessage.

Common situations: Pinning a version that was never published or was deleted from the feed; copying a version from a different package; stale docs referencing an old release; private feed missing the version.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/87e28cb33a519202. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Cli/Commands/AddCommand.cs:508

        // then we can skip the version prompt and just use that version.
        if (!string.IsNullOrEmpty(preferredVersion))
        {
            if (packageVersions.Any(p => p.Package.Version == preferredVersion))
            {
                var preferredVersionPackage = packageVersions.First(p => p.Package.Version == preferredVersion);
                return preferredVersionPackage;
            }

            var allVersions = await InteractionService.ShowStatusAsync(
                string.Format(CultureInfo.CurrentCulture, AddCommandStrings.SearchingForSpecifiedPackageVersion, selectedPackage.Package.Id, preferredVersion),
                async () => await GetAllPackageVersions(workingDirectory, packageVersions, cancellationToken));
            var matchedPreferredVersionPackage = allVersions.FirstOrDefault(packageVersion => packageVersion.Package.Version == preferredVersion);
            if (matchedPreferredVersionPackage.Package is not null)
            {
                return matchedPreferredVersionPackage;
            }

            throw new EmptyChoicesException(string.Format(CultureInfo.CurrentCulture, AddCommandStrings.SpecifiedVersionNotFoundForPackage, selectedPackage.Package.Id, preferredVersion));
        }

        // When PR hives are present, prefer the package that exactly matches the installed
        // CLI/SDK version so template- and add-generated projects stay on the same build.
        // IsBackedByLocalPackageDirectory also covers the ASPIRE_CLI_PACKAGES emulation case,
        // where the local channel is named stable/daily/staging rather than a local-build name.
        var prChannelPackageVersions = packageVersions
            .Where(p => VersionHelper.IsLocalBuildChannel(p.Channel.Name) || p.Channel.IsBackedByLocalPackageDirectory)
            .ToArray();

        if (VersionHelper.TryGetCurrentCliVersionMatch(
            prChannelPackageVersions,
            p => p.Package.Version,
            ExecutionContext.IdentitySdkVersion,
            out var cliVersionPackage,
            channelName: null,
            hasPrHives: ExecutionContext.GetHiveCount() > 0 || ExecutionContext.IdentityPackagesDirectory is not null))
        {

View on GitHub (pinned to 25830f84bd)