microsoft/aspire · error · InvalidOperationException

aspire-managed not found in layout.

Error message

aspire-managed not found in layout.

What it means

After finding a bundle layout, RestorePackagesAsync resolves layout.GetManagedPath() as the aspire-managed helper executable. If that path is null or the file is missing on disk, it throws this InvalidOperationException — the restore and manifest subcommands cannot be dispatched without the helper binary.

Solutions

  1. Repair or reinstall the Aspire CLI so the layout contains aspire-managed
  2. Clear the bundle extraction cache and let the CLI re-extract a fresh layout
  3. Verify antivirus/cleanup policies are not removing the managed binary
  4. Update the CLI to the latest version and retry the restore
Defensive patterns

Strategy: fallback

Validate before calling

// Verify the managed binary before attempting restore
var managedPath = layout.GetManagedPath();
if (managedPath is null || !File.Exists(managedPath))
{
    // reinstall the CLI bundle first
}

Try / catch

try
{
    await service.RestorePackagesAsync(packages, workingDir);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("aspire-managed not found"))
{
    // repair/reinstall bundle layout, clear cache, retry
}

Prevention

When it happens

Trigger: RestorePackagesAsync finds a layout whose GetManagedPath() is null or whose file does not exist (File.Exists check fails).

Common situations: Partial or corrupted bundle extraction; aspire-managed deleted by cleanup/antivirus; stale layout directory from an older install that lacks the managed binary; failed upgrade leaving an incomplete layout.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at src/Aspire.Cli/NuGet/BundleNuGetService.cs:93

        IEnumerable<string>? sources = null,
        string? nugetConfigPath = null,
        CancellationToken ct = default)
    {
        ArgumentException.ThrowIfNullOrWhiteSpace(workingDirectory);

        using var layoutLease = _bundleService is null
            ? null
            : await _bundleService.EnsureExtractedAndAcquireLayoutAsync("cli", "nuget-restore", ct).ConfigureAwait(false);
        var layout = layoutLease?.Layout ?? _layoutDiscovery.DiscoverLayout();
        if (layout is null)
        {
            throw new InvalidOperationException("Bundle layout not found. Cannot perform NuGet restore in bundle mode.");
        }

        var managedPath = layout.GetManagedPath();
        if (managedPath is null || !File.Exists(managedPath))
        {
            throw new InvalidOperationException("aspire-managed not found in layout.");
        }

        var packageList = packages.ToList();
        if (packageList.Count == 0)
        {
            throw new ArgumentException("At least one package is required", nameof(packages));
        }

        // Compute a hash for the package set to create a unique restore location.
        var packageHash = ComputePackageHash(packageList, targetFramework, runtimeIdentifier, managedPath, sources);
        var restoreCacheDirectory = GetPackageRestoreCacheDirectory(workingDirectory);
        var restoreDir = Path.Combine(restoreCacheDirectory, packageHash);
        var objDir = Path.Combine(restoreDir, "obj");
        var manifestPath = Path.Combine(restoreDir, IntegrationPackageProbeManifest.FileName);
        var assetsPath = Path.Combine(objDir, "project.assets.json");
        var lockPath = Path.Combine(restoreDir, "restore.lock");

        // The package cache is shared by every AppHost in the workspace. Serialize the

View on GitHub (pinned to 25830f84bd)