microsoft/aspire · error · EmptyChoicesException
No matching local Aspire.ProjectTemplates package was found…
Error message
No matching local Aspire.ProjectTemplates package was found for Aspire CLI version '{0}'. Build and stage matching packages with localhive.sh (macOS/Linux) or localhive.ps1 (Windows), set ASPIRE_CLI_PACKAGES to a directory containing the package, or explicitly choose feed-backed templates with --channel, --source, or --version. What it means
Thrown by ResolveTemplatePackageAsync when the CLI resolves templates locally but no staged Aspire.ProjectTemplates package version matches the CLI's own SDK version. The local package cache is expected to be populated by the localhive scripts so local CLI builds can find version-aligned template packages. Without a matching package, template creation cannot proceed.
Solutions
- Run ./eng/scripts/localhive.sh (macOS/Linux) or localhive.ps1 (Windows) to build and stage matching template packages.
- Set ASPIRE_CLI_PACKAGES to a directory containing an Aspire.ProjectTemplates package whose version matches the CLI's SDK version.
- Bypass local resolution by passing an explicit --channel, --source, or --version to use feed-backed templates.
- Verify the staged package version matches the CLI version with aspire --version.
Example fix
// before aspire new # local CLI, no staged packages // after export ASPIRE_CLI_PACKAGES=/path/to/staged/packages # or run localhive.sh first aspire new
Defensive patterns
Strategy: fallback
Validate before calling
var staged = Environment.GetEnvironmentVariable("ASPIRE_CLI_PACKAGES");
var hasLocalPackages = staged is not null && Directory.GetFiles(staged, "Aspire.ProjectTemplates.*.nupkg", SearchOption.TopDirectoryOnly).Length > 0;
var args = hasLocalPackages ? [] : ["--channel", "stable"]; Try / catch
try { await ResolveTemplatePackageAsync(...); }
catch (EmptyChoicesException ex) when (ex.Message.Contains("No matching local")) { // fall back to --channel/--source backed resolution
} Prevention
- Always run localhive.sh/localhive.ps1 after building the CLI locally.
- Keep ASPIRE_CLI_PACKAGES pointing at the localhive output directory.
- Re-stage packages after any version bump in the repo.
- Use explicit --channel/--source/--version when you don't need local packages.
When it happens
Trigger: Running a locally built Aspire CLI (unqualified local resolution, i.e. no --channel/--source/--version) whose IdentitySdkVersion has no corresponding Aspire.ProjectTemplates package in the packages-from-channels list — e.g. ASPIRE_CLI_PACKAGES unset or the directory lacks a package with that exact version string.
Common situations: Building the CLI from source and running it before running localhive.sh/localhive.ps1; a version bump in the repo makes the previously staged package version stale; ASPIRE_CLI_PACKAGES pointing at the wrong directory.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- No channel found matching
- Template version ' ' was not found.
- aspire-managed not found in layout.
- Bundle layout not found. Cannot perform NuGet restore in…
- Bundle layout not found. Cannot perform NuGet search in…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/3d1597e01d817bcd.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Cli/Templating/TemplateNuGetConfigService.cs:333
string.IsNullOrWhiteSpace(query.VersionOverride) &&
string.IsNullOrWhiteSpace(query.SourceOverride),
ct);
lock (resultsLock)
{
results.AddRange(templatePackages.Select(p => (p, channel)));
}
});
return results;
});
if (isUnqualifiedLocalResolution)
{
var localMatch = packagesFromChannels.FirstOrDefault(p =>
string.Equals(p.Package.Version, executionContext.IdentitySdkVersion, StringComparison.OrdinalIgnoreCase));
if (localMatch.Package is null)
{
throw new EmptyChoicesException(
string.Format(
CultureInfo.CurrentCulture,
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);View on GitHub (pinned to 25830f84bd)