{"record":{"id":"4dc018cb82c1a06a","repo":"microsoft/aspire","slug":"bundle-layout-not-found-cannot-perform-nuget-search-in","errorCode":null,"errorMessage":"Bundle layout not found. Cannot perform NuGet search in bundle mode.","messagePattern":"Bundle layout not found\\. Cannot perform NuGet search in bundle mode\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/NuGet/BundleNuGetPackageCache.cs","lineNumber":144,"sourceCode":"\n        bool FilterExactIdMatch(string? id) => string.Equals(id, exactPackageId, StringComparison.Ordinal);\n        return FilterPackages(packages, FilterExactIdMatch);\n    }\n\n    private async Task<IEnumerable<NuGetPackage>> SearchPackagesInternalAsync(\n        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","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/NuGet/BundleNuGetPackageCache.cs#L126-L162","documentation":"In bundle mode the Aspire CLI runs NuGet operations via an extracted self-contained bundle layout. SearchPackagesInternalAsync calls IBundleService.EnsureExtractedAndAcquireLayoutAsync and expects a layout lease; when the extracted layout is null (extraction failed or was not performed), it throws this InvalidOperationException because NuGet search cannot proceed without the bundle.","triggerScenarios":"Calling packages search / package-version listing through BundleNuGetPackageCache when EnsureExtractedAndAcquireLayoutAsync(\"cli\", \"nuget-search\") returns a lease whose Layout is null.","commonSituations":"Corrupted or partial CLI bundle installation; the bundle extraction directory was deleted or cleaned while the CLI runs; running a bundle-mode binary in an environment where extraction is disallowed (read-only disk, permissions); bundle service misconfigured so discovery yields no layout.","solutions":["Reinstall the Aspire CLI bundle so it can extract a valid layout","Check disk space and write permissions for the bundle extraction directory","Run the CLI once interactively to force extraction, then retry the package search","Update to the latest CLI version; report if bundle extraction consistently fails"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Precheck bundle availability before NuGet operations\nvar lease = await bundleService.EnsureExtractedAndAcquireLayoutAsync(\"cli\", \"precheck\", ct);\nif (lease?.Layout is null)\n{\n    // reinstall or fall back to non-bundle path\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await cache.SearchPackagesAsync(...);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Bundle layout not found\"))\n{\n    // repair install / re-extract bundle, then retry once\n}","preventionTips":["Reinstall the CLI cleanly when upgrading rather than copying binaries","Ensure the bundle extraction directory has free disk space and write permission","Avoid external cleanup jobs deleting the CLI's extraction cache while the CLI runs","Run the CLI once after install to complete first-run extraction before scripting"],"tags":["nuget","bundle","cli","installation"],"backgroundTag":"resource-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"}