microsoft/aspire · error · InvalidOperationException

No managed assemblies for package

Error message

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.

What it means

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.

Solutions

  1. Confirm the package id and version are correct and actually referenced by the AppHost project.
  2. Restore the project so managed asset paths for the package exist (dotnet restore, correct TFM).
  3. Rely on a probe manifest / generated package-to-assembly metadata so the canonical mapping is known; regenerate it if stale.
  4. If the package has no managed assemblies for the target framework, generate against the assembly-producing package instead.

Example fix

// before: package not referenced, no manifest mapping
var asm = await GenerateAsync(packageName: "Aspire.Hosting.Kafka.Css"); // no managed assemblies restored
// after
var asm = await GenerateAsync(packageName: "Aspire.Hosting.Kafka"); // referenced and restored, maps to Aspire.Hosting.Kafka.dll
Defensive patterns

Strategy: validation

Validate before calling

// verify the package id resolves to an assembly before generating
var ok = AtsContextFilter.TryResolveCanonicalAssemblyName(context, packageName, out var assemblyName);
if (!ok)
    throw new InvalidOperationException($"Package '{packageName}' has no managed assemblies mapped or scanned; check id/version and restore.");

Type guard

static bool PackageResolvable(string packageName, string context) =>
    AtsContextFilter.TryResolveCanonicalAssemblyName(context, packageName, out _);

Try / catch

try { var asm = ResolvePackageExportingAssemblyNames(pkg, version, context); }
catch (InvalidOperationException ex) when (ex.Message.Contains("No managed assemblies for package"))
{ log.LogError(ex, "Unresolvable package id: {0}", pkg); throw; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/6544ba991ba166d2. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.RemoteHost/CodeGeneration/CodeGenerationService.cs:418

            {
                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, " +
                "and the scanned API surface contains no assembly with the package id as its name.");
        }

        canonicalPackageName = canonicalAssemblyNameFromContext;
        return [canonicalAssemblyNameFromContext];
    }

    private string BuildApiExportLanguageList()
    {
        var exportable = _resolver.GetSupportedLanguages()
            .Where(language => _resolver.GetApiReferenceExporter(language) is not null)
            .OrderBy(language => language, StringComparer.OrdinalIgnoreCase)
            .ToArray();

        return exportable.Length == 0 ? "(none)" : string.Join(", ", exportable);
    }

View on GitHub (pinned to 25830f84bd)