{"record":{"id":"3d1597e01d817bcd","repo":"microsoft/aspire","slug":"no-matching-local-aspire-projecttemplates-package-was-found","errorCode":null,"errorMessage":"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.","messagePattern":"No matching local Aspire\\.ProjectTemplates package was found for Aspire CLI version '(.+?)'\\. 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\\.","errorType":"exception","errorClass":"EmptyChoicesException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Templating/TemplateNuGetConfigService.cs","lineNumber":333,"sourceCode":"                        string.IsNullOrWhiteSpace(query.VersionOverride) &&\n                        string.IsNullOrWhiteSpace(query.SourceOverride),\n                    ct);\n                lock (resultsLock)\n                {\n                    results.AddRange(templatePackages.Select(p => (p, channel)));\n                }\n            });\n\n            return results;\n        });\n\n        if (isUnqualifiedLocalResolution)\n        {\n            var localMatch = packagesFromChannels.FirstOrDefault(p =>\n                string.Equals(p.Package.Version, executionContext.IdentitySdkVersion, StringComparison.OrdinalIgnoreCase));\n            if (localMatch.Package is null)\n            {\n                throw new EmptyChoicesException(\n                    string.Format(\n                        CultureInfo.CurrentCulture,\n                        Resources.TemplatingStrings.NoMatchingLocalTemplatePackage,\n                        executionContext.IdentitySdkVersion));\n            }\n\n            return new TemplatePackageSelection(localMatch.Package, localMatch.Channel);\n        }\n\n        var orderedPackagesFromChannels = packagesFromChannels.OrderByDescending(p => Semver.SemVersion.Parse(p.Package.Version), Semver.SemVersion.PrecedenceComparer);\n\n        if (query.VersionOverride is { } version)\n        {\n            var explicitMatch = orderedPackagesFromChannels.FirstOrDefault(p =>\n                string.Equals(p.Package.Version, version, StringComparison.OrdinalIgnoreCase));\n            if (explicitMatch.Package is not null)\n            {\n                return new TemplatePackageSelection(explicitMatch.Package, explicitMatch.Channel);","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Templating/TemplateNuGetConfigService.cs#L315-L351","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\naspire new   # local CLI, no staged packages\n// after\nexport ASPIRE_CLI_PACKAGES=/path/to/staged/packages  # or run localhive.sh first\naspire new","handlingStrategy":"fallback","validationCode":"var staged = Environment.GetEnvironmentVariable(\"ASPIRE_CLI_PACKAGES\");\nvar hasLocalPackages = staged is not null && Directory.GetFiles(staged, \"Aspire.ProjectTemplates.*.nupkg\", SearchOption.TopDirectoryOnly).Length > 0;\nvar args = hasLocalPackages ? [] : [\"--channel\", \"stable\"];","typeGuard":null,"tryCatchPattern":"try { await ResolveTemplatePackageAsync(...); }\ncatch (EmptyChoicesException ex) when (ex.Message.Contains(\"No matching local\")) { // fall back to --channel/--source backed resolution\n}","preventionTips":["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."],"tags":["cli","nuget","version-mismatch","templates"],"backgroundTag":"missing-dependency","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}