{"record":{"id":"dce62c13214c11aa","repo":"microsoft/aspire","slug":"aspire-managed-not-found-in-layout","errorCode":null,"errorMessage":"aspire-managed not found in layout.","messagePattern":"aspire-managed not found in layout\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/NuGet/BundleNuGetPackageCache.cs","lineNumber":150,"sourceCode":"        DirectoryInfo workingDirectory,\n        string query,\n        bool exactMatch,\n        bool prerelease,\n        FileInfo? nugetConfigFile,\n        CancellationToken cancellationToken)\n    {\n        // Ensure the bundle is extracted and lease the version before launching aspire-managed.\n        using var layoutLease = await _bundleService.EnsureExtractedAndAcquireLayoutAsync(\"cli\", \"nuget-search\", cancellationToken).ConfigureAwait(false);\n        var layout = layoutLease?.Layout;\n        if (layout is null)\n        {\n            throw new InvalidOperationException(\"Bundle layout not found. Cannot perform NuGet search in bundle mode.\");\n        }\n\n        var managedPath = layout.GetManagedPath();\n        if (managedPath is null || !File.Exists(managedPath))\n        {\n            throw new InvalidOperationException(\"aspire-managed not found in layout.\");\n        }\n\n        // Build arguments for NuGet search command (via aspire-managed nuget subcommand)\n        var args = new List<string>\n        {\n            \"nuget\",\n            \"search\",\n            \"--query\", query,\n            \"--take\", \"1000\",\n            \"--format\", \"json\"\n        };\n\n        if (prerelease)\n        {\n            args.Add(\"--prerelease\");\n        }\n\n        // Pass working directory for nuget.config discovery","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/NuGet/BundleNuGetPackageCache.cs#L132-L168","documentation":"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.","triggerScenarios":"SearchPackagesInternalAsync (invoked by the packages MCP/CLI command) finds a layout whose GetManagedPath() returns null or points to a nonexistent file.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Precheck that the managed binary exists in the layout\nvar managedPath = layout.GetManagedPath();\nif (managedPath is null || !File.Exists(managedPath))\n{\n    // trigger reinstall/repair before proceeding\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await cache.SearchPackagesAsync(...);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"aspire-managed not found\"))\n{\n    // repair/reinstall the CLI bundle and retry\n}","preventionTips":["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"],"tags":["nuget","bundle","cli","missing-binary"],"backgroundTag":"file-not-found","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}