microsoft/aspire · error · InvalidOperationException

aspire-managed not found in layout.

Error message

aspire-managed not found in layout.

What it means

Bundle-mode NuGet search locates the aspire-managed helper binary inside the extracted layout via layout.GetManagedPath(). If the path is null or the file does not exist on disk, SearchPackagesInternalAsync throws this InvalidOperationException — the CLI cannot dispatch the nuget search subcommand without that executable.

Solutions

  1. Reinstall/repair the Aspire CLI bundle to restore a complete layout
  2. Delete the bundle extraction/cache directory and let the CLI re-extract
  3. Check that security software is not deleting the aspire-managed binary
  4. Update the CLI; if reproducible, file an issue with CLI version and OS details
Defensive patterns

Strategy: fallback

Validate before calling

// Precheck that the managed binary exists in the layout
var managedPath = layout.GetManagedPath();
if (managedPath is null || !File.Exists(managedPath))
{
    // trigger reinstall/repair before proceeding
}

Try / catch

try
{
    await cache.SearchPackagesAsync(...);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("aspire-managed not found"))
{
    // repair/reinstall the CLI bundle and retry
}

Prevention

When it happens

Trigger: SearchPackagesInternalAsync (invoked by the packages MCP/CLI command) finds a layout whose GetManagedPath() returns null or points to a nonexistent file.

Common situations: Incomplete or interrupted bundle extraction; a layout version mismatch where the extracted directory predates aspire-managed; antivirus or cleanup tools removing the binary; corrupted installation.

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/dce62c13214c11aa. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Cli/NuGet/BundleNuGetPackageCache.cs:150

        DirectoryInfo workingDirectory,
        string query,
        bool exactMatch,
        bool prerelease,
        FileInfo? nugetConfigFile,
        CancellationToken cancellationToken)
    {
        // Ensure the bundle is extracted and lease the version before launching aspire-managed.
        using var layoutLease = await _bundleService.EnsureExtractedAndAcquireLayoutAsync("cli", "nuget-search", cancellationToken).ConfigureAwait(false);
        var layout = layoutLease?.Layout;
        if (layout is null)
        {
            throw new InvalidOperationException("Bundle layout not found. Cannot perform NuGet search in bundle mode.");
        }

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

        // Build arguments for NuGet search command (via aspire-managed nuget subcommand)
        var args = new List<string>
        {
            "nuget",
            "search",
            "--query", query,
            "--take", "1000",
            "--format", "json"
        };

        if (prerelease)
        {
            args.Add("--prerelease");
        }

        // Pass working directory for nuget.config discovery

View on GitHub (pinned to 25830f84bd)