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
- Reinstall/repair the Aspire CLI bundle to restore a complete layout
- Delete the bundle extraction/cache directory and let the CLI re-extract
- Check that security software is not deleting the aspire-managed binary
- 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
- Keep antivirus exclusion rules for the CLI install/extraction directories
- Verify bundle integrity after upgrades or manual moves of the install directory
- Don't delete layout files manually; use the CLI's own repair/update mechanisms
- Pin and verify CLI version consistency across machines running shared scripts
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
- aspire-managed not found in layout.
- Bundle layout not found. Cannot perform NuGet restore in…
- Bundle layout not found. Cannot perform NuGet search in…
- Manifest creation failed
- aspire-managed not found in layout.
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 discoveryView on GitHub (pinned to 25830f84bd)