{"record":{"id":"f6d842da5ed983a0","repo":"microsoft/aspire","slug":"no-package-found-with-id-packageid-in-channel-context","errorCode":null,"errorMessage":"No package found with ID '{packageId}' in channel '{context.Channel.Name}'.","messagePattern":"No package found with ID '(.+?)' in channel '(.+?)'\\.","errorType":"exception","errorClass":"ProjectUpdaterException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Projects/ProjectUpdater.cs","lineNumber":395,"sourceCode":"    private async Task<NuGetPackageCli?> GetLatestVersionOfPackageAsync(UpdateContext context, string packageId, bool throwIfNotFound = true, CancellationToken cancellationToken = default)\n    {\n        var cacheKey = $\"LatestPackage-{packageId}\";\n        var latestPackage = await cache.GetOrCreateAsync(cacheKey, async entry =>\n        {\n            var packages = await context.Channel.GetPackagesAsync(packageId, context.AppHostProjectFile.Directory!, cancellationToken);\n            // Filter out packages with invalid semantic versions and find the latest valid one\n            var latestPackage = packages\n                .Where(p => SemVersion.TryParse(p.Version, SemVersionStyles.Strict, out _))\n                .OrderByDescending(p => SemVersion.Parse(p.Version, SemVersionStyles.Strict), SemVersion.PrecedenceComparer)\n                .FirstOrDefault();\n            return latestPackage;\n        });\n\n        if (latestPackage is null)\n        {\n            if (throwIfNotFound)\n            {\n                throw new ProjectUpdaterException(string.Format(CultureInfo.InvariantCulture, UpdateCommandStrings.NoPackageFoundFormat, packageId, context.Channel.Name));\n            }\n\n            logger.LogWarning(UpdateCommandStrings.PackageNotFoundInChannelWarningFormat, packageId, context.Channel.Name);\n            return null;\n        }\n\n        return latestPackage;\n    }\n\n    private async Task AnalyzeAppHostSdkAsync(UpdateContext context, CancellationToken cancellationToken)\n    {\n        logger.LogDebug(\"Analyzing App Host SDK for: {AppHostFile}\", context.AppHostProjectFile.FullName);\n\n        var itemsAndPropertiesDocument = await GetItemsAndPropertiesWithFallbackAsync(context.AppHostProjectFile, context, cancellationToken);\n        var propertiesElement = itemsAndPropertiesDocument.RootElement.GetProperty(\"Properties\");\n        var sdkVersionElement = propertiesElement.GetProperty(\"AspireHostingSDKVersion\");\n        var sdkVersion = sdkVersionElement.GetString();\n","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Projects/ProjectUpdater.cs#L377-L413","documentation":"GetLatestVersionOfPackageAsync queries the configured package channel for the newest version of a package ID. When the channel returns no package and throwIfNotFound is true, it throws ProjectUpdaterException with NoPackageFoundFormat naming the package ID and channel; when throwIfNotFound is false it only logs a warning and returns null, letting the updater skip that package.","triggerScenarios":"GetLatestVersionOfPackageAsync (used by latestSdkPackage/latestPackage flows) querying a channel whose package search yields no entry for the requested packageId, with throwIfNotFound=true — i.e. an explicit channel missing the package.","commonSituations":"Explicit channel configured with a narrow feed (staging mirror, pinned NuGet.config source) that does not host the package; typo in package ID; the package was renamed/unlisted upstream; offline or partially-synced mirror missing recent packages; version range filters excluding all published versions.","solutions":["Check the package ID spelling against the project file — IDs are case-sensitive in some feeds.","Verify the package exists on the channel's feed (open the feed URL / dotnet package search) and that the mirror is synced.","Add the missing source (e.g. nuget.org) to the channel's NuGet.config, or switch to a channel that includes it.","If the package is intentionally optional, use the non-throwing path so the updater logs a warning and skips it instead of failing the update."],"exampleFix":"// before (feed missing the package)\n<packageSources><add key=\"internal-mirror\" value=\"https://mirror.internal/limited/v3/index.json\" /></packageSources>\n// after (add upstream)\n<packageSources><add key=\"internal-mirror\" value=\"https://mirror.internal/limited/v3/index.json\" /><add key=\"nuget\" value=\"https://api.nuget.org/v3/index.json\" /></packageSources>","handlingStrategy":"validation","validationCode":"// Verify the package exists on the channel's feed before updating\nvar search = await dotnet.RunAsync($\"package search {packageId} --source {feedUrl}\");\nif (search.ExitCode != 0 || string.IsNullOrWhiteSpace(search.Stdout))\n    throw new InvalidOperationException($\"{packageId} not found on {feedUrl}\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var version = await updater.GetLatestVersionOfPackageAsync(packageId, context, throwIfNotFound: true, cancellationToken);\n}\ncatch (ProjectUpdaterException ex) when (ex.Message.Contains(\"No package found\"))\n{\n    Console.Error.WriteLine($\"{packageId} missing from channel; check feed config or ID spelling.\");\n}","preventionTips":["Use non-throwing lookup (log-and-skip) for optional packages in update automation.","Keep channel feeds (nuget.org or a fully-synced mirror) reachable and current.","Double-check package IDs — a typo surfaces as 'package not found'.","Audit explicit channel NuGet.config sources to confirm they host all packages in the solution."],"tags":["cli","nuget","package-lookup","update"],"backgroundTag":"package-not-found","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}