Skip to content

Commit 515d325

Browse files
committed
Fixed startup in VS Code
1 parent c53a5a9 commit 515d325

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Fixed floating point display resolution (#944) @softworkz
99
- Fixed previous API break using exposed `JsonElement` objects (#938) @softworkz
1010
- Fixed and improved several test cases (#962) @softworkz
11+
- Fixed startup of Electron.NET from VS Code Debug Adapter (#952)
1112
- Fixed the `BrowserWindowOptions` (#945) @softworkz
1213
- Added several migration checks for publishing (#966) @softworkz
1314
- Added more test runners for E2E tests (#950, #951) @agracio

src/ElectronNET.AspNet/API/WebHostBuilderExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public static class WebHostBuilderExtensions
6060
public static IWebHostBuilder UseElectron(this IWebHostBuilder builder, string[] args, Func<Task> onAppReadyCallback)
6161
{
6262
ElectronNetRuntime.OnAppReadyCallback = onAppReadyCallback;
63+
64+
// no matter how this is set - let's unset to prevent Electron not starting as expected
65+
// e.g., VS Code sets this env variable, but this will cause `require("electron")` to not
66+
// work as expected, see issue #952
67+
Environment.SetEnvironmentVariable("ELECTRON_RUN_AS_NODE", null);
6368

6469
var webPort = PortHelper.GetFreePort(ElectronNetRuntime.AspNetWebPort ?? ElectronNetRuntime.DefaultWebPort);
6570
ElectronNetRuntime.AspNetWebPort = webPort;

0 commit comments

Comments
 (0)