microsoft/aspire · error · InvalidOperationException
Package ' ' version ' ' was mapped from restored asset…
Error message
Package '{packageName}' version '{packageVersion}' was mapped from restored asset paths, but none of its assemblies reached the scanned API surface. What it means
ResolvePackageExportingAssemblyNames maps a NuGet package id+version to the assembly names that contributed to the scanned API surface, using restored asset paths. If the mapping produced entries but none of the package's assemblies actually appear in the scanned API surface, it throws this InvalidOperationException. It guards against publishing source-generation documents keyed to a package whose code never made it into the scan.
Solutions
- Reference the package in the AppHost so its assemblies participate in the scanned API surface.
- Rerun generation without a scoped assemblyName, or scope to an assembly that is actually in the scan.
- Clean and restore so the restored asset paths match the current package versions.
- Verify the package actually contains managed assemblies for the target framework (not a metadata-only or tools-only package).
Example fix
// before: AppHost does not reference the package being generated for // after <PackageReference Include="Aspire.Hosting.Redis" Version="9.2.0" /> // package now reaches the scanned API surface
Defensive patterns
Strategy: validation
Validate before calling
// ensure the package is referenced by the AppHost and present in the scanned surface
var scanned = await client.GetScannedAssemblyNames();
if (!scanned.Any(a => a.StartsWith("Aspire.Hosting", StringComparison.OrdinalIgnoreCase)))
throw new InvalidOperationException("Package assemblies absent from scanned API surface; reference the package in the AppHost."); Type guard
static bool PackageInScan(string packageName, IEnumerable<string> scannedAssemblies) =>
scannedAssemblies.Any(a => a.Equals(packageName, StringComparison.OrdinalIgnoreCase)); Try / catch
try { var asm = ResolvePackageExportingAssemblyNames(pkg, version, context); }
catch (InvalidOperationException ex) when (ex.Message.Contains("none of its assemblies reached the scanned API surface"))
{ log.LogError(ex, "Package not part of scanned surface"); throw; } Prevention
- Reference the package from the AppHost project so it participates in the scan.
- Clean/restore after version changes so asset-path manifests are current.
- Scope generation to assemblies that actually appear in the exported document.
When it happens
Trigger: Calling code generation for a package whose asset-path manifest maps to assemblies that were excluded from the ATS scan (API-export filter, scoped-context filtering), so exportingAssemblyNames ends up empty after cross-checking the scanned surface.
Common situations: Requesting generation for a package that is referenced on disk but not part of the scanned app model; package restored but its assemblies filtered out by the export filter; stale manifest pointing at an old package layout.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- No managed assemblies for package
- aspire: returned unexpected type %T
- No code generator found for language
- no input with name ' ' was found
- -32602
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/548584dc4365f51a.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.RemoteHost/CodeGeneration/CodeGenerationService.cs:401
{
if (_assemblyLoader.TryGetPackageAssemblyNamesFromProbePaths(
packageName,
packageVersion,
out var manifestAssemblyNames,
out var manifestPackageName))
{
var exportingAssemblyNames = new List<string>(manifestAssemblyNames.Count);
foreach (var assemblyName in manifestAssemblyNames)
{
if (AtsContextFilter.TryResolveCanonicalAssemblyName(fullContext, assemblyName, out var canonicalAssemblyName))
{
exportingAssemblyNames.Add(canonicalAssemblyName);
}
}
if (exportingAssemblyNames.Count == 0)
{
throw new InvalidOperationException(
$"Package '{packageName}' version '{packageVersion}' was mapped from restored asset paths, " +
"but none of its assemblies reached the scanned API surface.");
}
canonicalPackageName = manifestPackageName;
return exportingAssemblyNames;
}
// A NuGet package id is case-insensitive
// (https://learn.microsoft.com/nuget/consume-packages/finding-and-choosing-packages#package-identifiers)
// but the exported document records this string verbatim as the identity consumers key
// on, so `aspire.hosting.redis` would publish a document naming a package nobody looks
// up. For local project references and older probe manifests we do not have package-to-
// assembly metadata, so the loaded assembly settles the spelling as before.
if (!AtsContextFilter.TryResolveCanonicalAssemblyName(fullContext, packageName, out var canonicalAssemblyNameFromContext))
{
throw new InvalidOperationException(
$"No managed assemblies for package '{packageName}' version '{packageVersion}' could be mapped from the restored asset paths, " +View on GitHub (pinned to 25830f84bd)