From 69a703748026b4890db2e6ce683c05f5f3fffe1c Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Fri, 5 Jul 2019 18:00:55 -0700 Subject: [PATCH] Revert "Remove some dead code in Blazor hosting" This reverts commit d8b1af39f06e4c170dae3fd01b5ca4d49e16c4a3. This wasn't dead-code after all. Removing this code breaks the Components functional tests (at least running locally). --- .../BlazorHostingEndpointRouteBuilderExtensions.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Components/Blazor/Server/src/Builder/BlazorHostingEndpointRouteBuilderExtensions.cs b/src/Components/Blazor/Server/src/Builder/BlazorHostingEndpointRouteBuilderExtensions.cs index f800c941ca..f899f2576f 100644 --- a/src/Components/Blazor/Server/src/Builder/BlazorHostingEndpointRouteBuilderExtensions.cs +++ b/src/Components/Blazor/Server/src/Builder/BlazorHostingEndpointRouteBuilderExtensions.cs @@ -168,7 +168,19 @@ namespace Microsoft.AspNetCore.Builder throw new ArgumentNullException(nameof(filePath)); } + var config = BlazorConfig.Read(clientAssemblyFilePath); + + // We want to serve "index.html" from whichever directory contains it in this priority order: + // 1. Client app "dist" directory + // 2. Client app "wwwroot" directory + // 3. Server app "wwwroot" directory var directory = endpoints.ServiceProvider.GetRequiredService().WebRootPath; + var indexHtml = config.FindIndexHtmlFile(); + if (indexHtml != null) + { + directory = Path.GetDirectoryName(indexHtml); + } + var options = new StaticFileOptions() { FileProvider = new PhysicalFileProvider(directory),