microsoft/aspire · error · EmptyChoicesException

Template version ' ' was not found.

Error message

Template version '{0}' was not found.

What it means

Thrown by ResolveTemplatePackageAsync when an explicit template --version was requested but no Aspire.ProjectTemplates package with that exact version string exists on any configured channel/source. The comparison is an exact ordinal string match on the package version.

Solutions

  1. List available versions (aspire search / check the feed) and use an exact existing version string.
  2. Add the NuGet source that contains the requested version with --source or NuGet.config.
  3. Drop the explicit --version to let the CLI pick the latest matching version.
  4. Check for typos or extra whitespace in the version argument.

Example fix

// before
aspire new --version 9.4.99   # not published
// after
aspire new --version 9.4.0    # an existing published version (or omit --version)
Defensive patterns

Strategy: validation

Validate before calling

// validate the requested version exists before resolution
var available = await packagingService.GetTemplatePackageVersionsAsync(ct);
if (!available.Contains(requestedVersion, StringComparer.OrdinalIgnoreCase))
{
    throw new ArgumentException($"Version {requestedVersion} not available. Available: {string.Join(", ", available)}");
}

Try / catch

try { await ResolveTemplatePackageAsync(...); }
catch (EmptyChoicesException) { // prompt user or retry with latest version
}

Prevention

When it happens

Trigger: Calling template resolution with an explicit version (via --version or equivalent API) that no available package matches — typo, unpublished version, or a version not present on the configured feeds.

Common situations: Typo in the version string; pinning a version only published to a feed not configured in NuGet.config; requesting a version newer than any staged/published package; offline feeds.

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/51de6e6cb4bc732c. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Cli/Templating/TemplateNuGetConfigService.cs:354

                        Resources.TemplatingStrings.NoMatchingLocalTemplatePackage,
                        executionContext.IdentitySdkVersion));
            }

            return new TemplatePackageSelection(localMatch.Package, localMatch.Channel);
        }

        var orderedPackagesFromChannels = packagesFromChannels.OrderByDescending(p => Semver.SemVersion.Parse(p.Package.Version), Semver.SemVersion.PrecedenceComparer);

        if (query.VersionOverride is { } version)
        {
            var explicitMatch = orderedPackagesFromChannels.FirstOrDefault(p =>
                string.Equals(p.Package.Version, version, StringComparison.OrdinalIgnoreCase));
            if (explicitMatch.Package is not null)
            {
                return new TemplatePackageSelection(explicitMatch.Package, explicitMatch.Channel);
            }

            throw new EmptyChoicesException(
                string.Format(
                    CultureInfo.CurrentCulture,
                    Resources.TemplatingStrings.TemplateVersionNotFound,
                    version));
        }

        if (!packagesFromChannels.Any())
        {
            throw new EmptyChoicesException(Resources.TemplatingStrings.NoTemplateVersionsFound);
        }

        if (VersionHelper.TryGetCurrentCliVersionMatch(
            orderedPackagesFromChannels,
            p => p.Package.Version,
            executionContext.IdentitySdkVersion,
            out var cliVersionMatch,
            channelName: query.RequestedChannel,
            hasPrHives: hasPrHives))

View on GitHub (pinned to 25830f84bd)