{"record":{"id":"6544ba991ba166d2","repo":"microsoft/aspire","slug":"no-managed-assemblies-for-package-packagename-version","errorCode":null,"errorMessage":"No managed assemblies for package '{packageName}' version '{packageVersion}' could be mapped from the restored asset paths, and the scanned API surface contains no assembly with the package id as its name.","messagePattern":"No managed assemblies for package '(.+?)' version '(.+?)' could be mapped from the restored asset paths, and the scanned API surface contains no assembly with the package id as its name\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.RemoteHost/CodeGeneration/CodeGenerationService.cs","lineNumber":418,"sourceCode":"            {\n                throw new InvalidOperationException(\n                    $\"Package '{packageName}' version '{packageVersion}' was mapped from restored asset paths, \" +\n                    \"but none of its assemblies reached the scanned API surface.\");\n            }\n\n            canonicalPackageName = manifestPackageName;\n            return exportingAssemblyNames;\n        }\n\n        // A NuGet package id is case-insensitive\n        // (https://learn.microsoft.com/nuget/consume-packages/finding-and-choosing-packages#package-identifiers)\n        // but the exported document records this string verbatim as the identity consumers key\n        // on, so `aspire.hosting.redis` would publish a document naming a package nobody looks\n        // up. For local project references and older probe manifests we do not have package-to-\n        // assembly metadata, so the loaded assembly settles the spelling as before.\n        if (!AtsContextFilter.TryResolveCanonicalAssemblyName(fullContext, packageName, out var canonicalAssemblyNameFromContext))\n        {\n            throw new InvalidOperationException(\n                $\"No managed assemblies for package '{packageName}' version '{packageVersion}' could be mapped from the restored asset paths, \" +\n                \"and the scanned API surface contains no assembly with the package id as its name.\");\n        }\n\n        canonicalPackageName = canonicalAssemblyNameFromContext;\n        return [canonicalAssemblyNameFromContext];\n    }\n\n    private string BuildApiExportLanguageList()\n    {\n        var exportable = _resolver.GetSupportedLanguages()\n            .Where(language => _resolver.GetApiReferenceExporter(language) is not null)\n            .OrderBy(language => language, StringComparer.OrdinalIgnoreCase)\n            .ToArray();\n\n        return exportable.Length == 0 ? \"(none)\" : string.Join(\", \", exportable);\n    }\n","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.RemoteHost/CodeGeneration/CodeGenerationService.cs#L400-L436","documentation":"When no managed assemblies for the package can be mapped from restored asset paths, the service falls back to matching an assembly in the scanned API surface whose simple name equals the package id (via AtsContextFilter.TryResolveCanonicalAssemblyName). If that also fails, it throws this InvalidOperationException. In effect: neither the restore manifest nor the scanned surface can attribute any assembly to the requested package.","triggerScenarios":"Resolving exporting assemblies for a package id that has no managed DLLs among restored asset paths (native/metadata-only package, wrong TFM restore) and whose id also matches no scanned assembly name — e.g. snake_case package ids like 'aspire.hosting.redis' that never equal an assembly simple name.","commonSituations":"Requesting generation for a package not actually used by the app; probing/manifest files missing so asset paths can't be resolved; package id casing/format differing from the assembly name with no probe manifest to supply the canonical mapping.","solutions":["Confirm the package id and version are correct and actually referenced by the AppHost project.","Restore the project so managed asset paths for the package exist (dotnet restore, correct TFM).","Rely on a probe manifest / generated package-to-assembly metadata so the canonical mapping is known; regenerate it if stale.","If the package has no managed assemblies for the target framework, generate against the assembly-producing package instead."],"exampleFix":"// before: package not referenced, no manifest mapping\nvar asm = await GenerateAsync(packageName: \"Aspire.Hosting.Kafka.Css\"); // no managed assemblies restored\n// after\nvar asm = await GenerateAsync(packageName: \"Aspire.Hosting.Kafka\"); // referenced and restored, maps to Aspire.Hosting.Kafka.dll","handlingStrategy":"validation","validationCode":"// verify the package id resolves to an assembly before generating\nvar ok = AtsContextFilter.TryResolveCanonicalAssemblyName(context, packageName, out var assemblyName);\nif (!ok)\n    throw new InvalidOperationException($\"Package '{packageName}' has no managed assemblies mapped or scanned; check id/version and restore.\");","typeGuard":"static bool PackageResolvable(string packageName, string context) =>\n    AtsContextFilter.TryResolveCanonicalAssemblyName(context, packageName, out _);","tryCatchPattern":"try { var asm = ResolvePackageExportingAssemblyNames(pkg, version, context); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"No managed assemblies for package\"))\n{ log.LogError(ex, \"Unresolvable package id: {0}\", pkg); throw; }","preventionTips":["Use the exact NuGet package id, not a loose alias or snake_case variant.","Run dotnet restore so managed asset paths exist before generation.","Regenerate package-to-assembly probe manifests after dependency changes."],"tags":["code-generation","nuget","package-mapping","assembly-resolution"],"backgroundTag":"resource-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"}