{"record":{"id":"c53c0384a4c699b4","repo":"microsoft/aspire","slug":"aspire-managed-not-found-in-layout-bundlenugetservice","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/BundleNuGetService.cs","lineNumber":93,"sourceCode":"        IEnumerable<string>? sources = null,\n        string? nugetConfigPath = null,\n        CancellationToken ct = default)\n    {\n        ArgumentException.ThrowIfNullOrWhiteSpace(workingDirectory);\n\n        using var layoutLease = _bundleService is null\n            ? null\n            : await _bundleService.EnsureExtractedAndAcquireLayoutAsync(\"cli\", \"nuget-restore\", ct).ConfigureAwait(false);\n        var layout = layoutLease?.Layout ?? _layoutDiscovery.DiscoverLayout();\n        if (layout is null)\n        {\n            throw new InvalidOperationException(\"Bundle layout not found. Cannot perform NuGet restore 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        var packageList = packages.ToList();\n        if (packageList.Count == 0)\n        {\n            throw new ArgumentException(\"At least one package is required\", nameof(packages));\n        }\n\n        // Compute a hash for the package set to create a unique restore location.\n        var packageHash = ComputePackageHash(packageList, targetFramework, runtimeIdentifier, managedPath, sources);\n        var restoreCacheDirectory = GetPackageRestoreCacheDirectory(workingDirectory);\n        var restoreDir = Path.Combine(restoreCacheDirectory, packageHash);\n        var objDir = Path.Combine(restoreDir, \"obj\");\n        var manifestPath = Path.Combine(restoreDir, IntegrationPackageProbeManifest.FileName);\n        var assetsPath = Path.Combine(objDir, \"project.assets.json\");\n        var lockPath = Path.Combine(restoreDir, \"restore.lock\");\n\n        // The package cache is shared by every AppHost in the workspace. Serialize the","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/NuGet/BundleNuGetService.cs#L75-L111","documentation":"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.","triggerScenarios":"RestorePackagesAsync finds a layout whose GetManagedPath() is null or whose file does not exist (File.Exists check fails).","commonSituations":"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.","solutions":["Repair or reinstall the Aspire CLI so the layout contains aspire-managed","Clear the bundle extraction cache and let the CLI re-extract a fresh layout","Verify antivirus/cleanup policies are not removing the managed binary","Update the CLI to the latest version and retry the restore"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Verify the managed binary before attempting restore\nvar managedPath = layout.GetManagedPath();\nif (managedPath is null || !File.Exists(managedPath))\n{\n    // reinstall the CLI bundle first\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await service.RestorePackagesAsync(packages, workingDir);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"aspire-managed not found\"))\n{\n    // repair/reinstall bundle layout, clear cache, retry\n}","preventionTips":["After CLI updates, confirm the extraction directory contains aspire-managed","Exclude CLI directories from aggressive disk cleaners and AV quarantine","Use official installers/updaters so layout contents stay complete","Keep one consistent CLI version per machine to avoid stale layouts"],"tags":["nuget","bundle","restore","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"}