{"record":{"id":"ddd2b6c15737dfac","repo":"microsoft/aspire","slug":"scriptname-not-found-at-scriptpath-ensure-the-aspire-hosting","errorCode":null,"errorMessage":"{scriptName} not found at '{scriptPath}'. Ensure the Aspire.Hosting.Blazor package includes the file as content.","messagePattern":"(.+?) not found at '(.+?)'\\. Ensure the Aspire\\.Hosting\\.Blazor package includes the file as content\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Blazor/BlazorGatewayExtensions.cs","lineNumber":586,"sourceCode":"                        /app/output/{{pathPrefix}}.endpoints.json\n                \"\"\";\n        });\n\n        gateway.WithAnnotation(new ContainerFilesDestinationAnnotation\n        {\n            Source = companion.Resource,\n            DestinationPath = \".\"\n        });\n    }\n\n    private static string GetScriptPath(string scriptName)\n    {\n        var assemblyDir = Path.GetDirectoryName(typeof(BlazorGatewayExtensions).Assembly.Location)!;\n        var scriptPath = Path.Combine(assemblyDir, \"Scripts\", scriptName);\n\n        if (!File.Exists(scriptPath))\n        {\n            throw new FileNotFoundException(\n                $\"{scriptName} not found at '{scriptPath}'. Ensure the Aspire.Hosting.Blazor package includes the file as content.\");\n        }\n\n        return scriptPath;\n    }\n\n    private const string AspireStorePathKey = \"Aspire:Store:Path\";\n\n    /// <summary>\n    /// Gets the Blazor-specific store path under the Aspire store directory.\n    /// </summary>\n    private static string GetBlazorStorePath(IDistributedApplicationBuilder builder)\n    {\n        var storePath = builder.Configuration[AspireStorePathKey]\n            ?? builder.AppHostDirectory;\n\n        return Path.Combine(storePath, \".aspire\", \"blazor\");\n    }","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Blazor/BlazorGatewayExtensions.cs#L568-L604","documentation":"GetScriptPath resolves bundled gateway scripts (e.g. Gateway.cs) from the Aspire.Hosting.Blazor assembly directory. If the expected script file is missing from disk next to the assembly, it throws FileNotFoundException telling you the package should include it as content.","triggerScenarios":"Calling AddDotnetProjectBlazorGateway/GetScriptPath when the assembly's directory lacks Scripts/<scriptName> — typically after copying only the DLL, using a broken/local build, or a packaging bug where content items weren't shipped.","commonSituations":"Non-standard deployment of the host assembly (xcopy of a single DLL); trimmed publish dropping content files; building the package locally without content globs; custom bin layout.","solutions":["Reinstall/repair the Aspire.Hosting.Blazor NuGet package so Scripts/*.cs content files ship with it.","Verify Scripts/Gateway.cs exists next to Aspire.Hosting.Blazor.dll and fix the deployment to copy content files.","If building the package locally, fix the csproj content-include globs for the Scripts folder.","Run from a normal dotnet build/package layout instead of hand-copied assemblies."],"exampleFix":"<!-- before: Scripts folder not included -->\n<!-- after -->\n<ItemGroup>\n  <Content Include=\"Scripts\\**\\*\" CopyToOutputDirectory=\"PreserveNewest\" Pack=\"true\" PackagePath=\"contentFiles\" />\n</ItemGroup>","handlingStrategy":"fallback","validationCode":"var scriptPath = Path.Combine(Path.GetDirectoryName(typeof(BlazorGatewayExtensions).Assembly.Location)!, \"Scripts\", \"Gateway.cs\");\nif (!File.Exists(scriptPath)) throw new InvalidOperationException($\"Aspire.Hosting.Blazor content missing: {scriptPath}\");","typeGuard":null,"tryCatchPattern":"try { AddDotnetProjectBlazorGateway(builder, ...); } catch (FileNotFoundException ex) when (ex.Message.Contains(\"Ensure the Aspire.Hosting.Blazor package\")) { logger.LogError(ex, \"Reinstall Aspire.Hosting.Blazor; Scripts content not shipped\"); throw; }","preventionTips":["Deploy the full package output, not hand-copied DLLs.","Verify package content files in CI when building Aspire locally.","Avoid publishes that trim content items from Aspire.Hosting.Blazor."],"tags":["blazor","gateway","file-not-found","packaging","scripts"],"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"}