From 7fa5ec5b0bdd2572f469dc7f41fc2a63f91cab8a Mon Sep 17 00:00:00 2001 From: Florian Rappl Date: Mon, 3 Aug 2026 14:09:01 +0200 Subject: [PATCH] Fixed #1050 --- Changelog.md | 5 +++++ src/ElectronNET.AspNet/API/WebHostBuilderExtensions.cs | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Changelog.md b/Changelog.md index b573d7c..3873f04 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,11 @@ ## ElectronNET.Core - Fixed token param being appended to external URLs (#1075) +- Fixed startup mode discriminator in case of existing `wwwroot` (#1050) +- Fixed CA1416 on ASP.NET project (#1091) @epsnm +- Fixed loading issue in plain Visual Studio (#1084) @epsnm +- Fixed bloated ASAR file (#1080) @epsnm +- Improved selection of runtime identifier (#1081) @epsnm - Added more variants for `UseElectron` (#1076) @AeonSake # 0.5.1 diff --git a/src/ElectronNET.AspNet/API/WebHostBuilderExtensions.cs b/src/ElectronNET.AspNet/API/WebHostBuilderExtensions.cs index 2812474..d3508b3 100644 --- a/src/ElectronNET.AspNet/API/WebHostBuilderExtensions.cs +++ b/src/ElectronNET.AspNet/API/WebHostBuilderExtensions.cs @@ -216,14 +216,16 @@ var webPort = ElectronNetRuntime.AspNetWebPort ?? 0; - // check for the content folder if its exists in base director otherwise no need to include - // It was used before because we are publishing the project which copies everything to bin folder and contentroot wwwroot was folder there. - // now we have implemented the live reload if app is run using /watch then we need to use the default project path. + // In packaged mode, static content is deployed alongside the app binaries, so we must + // point content root to the process base directory. In unpackaged/watch scenarios we + // keep the default project content root to preserve live reload behavior. + var isPackagedStartup = ElectronNetRuntime.StartupMethod == StartupMethod.PackagedElectronFirst || + ElectronNetRuntime.StartupMethod == StartupMethod.PackagedDotnetFirst; // For port 0 (dynamic port assignment), Kestrel requires binding to specific IP (127.0.0.1) not localhost var host = webPort == 0 ? "127.0.0.1" : "localhost"; - if (Directory.Exists($"{AppDomain.CurrentDomain.BaseDirectory}\\wwwroot")) + if (isPackagedStartup) { builder = builder.UseContentRoot(AppDomain.CurrentDomain.BaseDirectory) .UseUrls($"http://{host}:{webPort}");