Upgrade ElectronNET to ElectronNET.Core 0.4.1#3
Conversation
There was a problem hiding this comment.
Pull request overview
Upgrades the desktop packaging/runtime setup for Nine’s Electron-hosted Blazor app, including moving to ElectronNET.Core and adjusting publish/build configuration to better support OS-specific deployment.
Changes:
- Replace
ElectronNET.APIpackage usage withElectronNET.Core/ElectronNET.Core.AspNetand update Electron-related MSBuild properties. - Rework Electron startup flow in
Program.cs(Electron “ready” callback) and simplify path handling to use OS user-data locations. - Add electron-builder config + publish profiles and update ignore rules for publish output.
Reviewed changes
Copilot reviewed 11 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| 4-Nine/desktop-config.bk | Adds a desktop config backup/legacy file for Electron packaging settings. |
| 4-Nine/Shared/Components/Account/Pages/Register.razor | Comments out external login registration section in the UI. |
| 4-Nine/Shared/App.razor | Updates the referenced isolated CSS bundle filename. |
| 4-Nine/Services/ElectronPathService.cs | Simplifies DB/user-data path resolution to always use OS user-data path. |
| 4-Nine/Properties/electron-builder.json | Adds electron-builder packaging configuration (mac/win/linux). |
| 4-Nine/Properties/PublishProfiles/win-x64.pubxml | Adds Windows self-contained publish profile. |
| 4-Nine/Properties/PublishProfiles/linux-x64.pubxml | Adds Linux self-contained publish profile. |
| 4-Nine/Program.cs | Switches to Electron-only startup path and adds Electron “ready” callback window creation. |
| 4-Nine/Nine.csproj | Moves to ElectronNET.Core packages, adds Electron-related MSBuild properties, sets RID per OS. |
| 4-Nine/ElectronHostHook/tsconfig.json | Removes ElectronHostHook TypeScript config. |
| 4-Nine/ElectronHostHook/package.json | Removes ElectronHostHook npm package manifest. |
| 4-Nine/ElectronHostHook/package-lock.json | Removes ElectronHostHook npm lockfile. |
| 1-Nine.Infrastructure/Nine.Infrastructure.csproj | Adds ASP.NET Core framework reference; removes ElectronNET.API package reference. |
| .gitignore | Ignores Electron publish output directory. |
Files not reviewed (1)
- 4-Nine/ElectronHostHook/package-lock.json: Language not supported
You can also share your feedback on Copilot code review. Take the survey.
| @@ -53,11 +47,8 @@ | |||
| builder.Services.AddAntiforgery(options => | |||
| { | |||
| options.HeaderName = "X-CSRF-TOKEN"; | |||
| // Allow cookies over HTTP for Electron/Development | |||
| if (HybridSupport.IsElectronActive || builder.Environment.IsDevelopment()) | |||
| { | |||
| options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest; | |||
| } | |||
| // Electron runs over plain HTTP — cookies must not require HTTPS | |||
| options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest; | |||
| }); | |||
|
|
|||
|
|
|||
| @@ -77,15 +68,8 @@ | |||
| builder.Services.AddScoped<IdentityRedirectManager>(); | |||
| builder.Services.AddScoped<AuthenticationStateProvider, IdentityRevalidatingAuthenticationStateProvider>(); | |||
|
|
|||
| // Add platform-specific infrastructure services (Database, Identity, Path services) | |||
| if (HybridSupport.IsElectronActive) | |||
| { | |||
| builder.Services.AddElectronServices(builder.Configuration); | |||
| } | |||
| else | |||
| { | |||
| builder.Services.AddWebServices(builder.Configuration); | |||
| } | |||
| // Electron-only: always use Electron services (user-data DB path, etc.) | |||
| builder.Services.AddElectronServices(builder.Configuration); | |||
There was a problem hiding this comment.
This change makes the app Electron-only (always UseElectron, fixed URL binding to :8888, and always AddElectronServices) and removes the previous web-mode branching. The PR description only mentions upgrading ElectronNET and path/RID fixes; if web hosting is still a supported deployment, this is a breaking behavior change that should either be reverted or explicitly documented/guarded behind a config flag.
| <link rel="stylesheet" href="@Assets["app.css"]" /> | ||
| <link rel="stylesheet" href="_content/Nine.Shared.UI/css/organization-switcher.css" /> | ||
| <link rel="stylesheet" href="@Assets["Nine.styles.css"]" /> | ||
| <link rel="stylesheet" href="@Assets["co.nineapp.nine.styles.css"]" /> |
There was a problem hiding this comment.
The isolated CSS bundle name is typically based on the project/assembly name (defaulting to Nine.styles.css). This project file doesn’t set <AssemblyName>, so referencing co.nineapp.nine.styles.css is likely to 404 and drop component-scoped styles. Either set <AssemblyName> to match, or revert the link to the actual generated *.styles.css name.
| <link rel="stylesheet" href="@Assets["co.nineapp.nine.styles.css"]" /> | |
| <link rel="stylesheet" href="@Assets["Nine.styles.css"]" /> |
| "files": ["**/*"], | ||
| "mac": { | ||
| "target": "dmg", | ||
| "icon": "Assets/icon.icns", |
There was a problem hiding this comment.
The macOS build config points to Assets/icon.icns, but there is no icon.icns under 4-Nine/Assets/ in this repo (only icon.png and icon.ico). Packaging for macOS will fail unless an .icns is added or the config is updated to a file that exists.
| "icon": "Assets/icon.icns", | |
| "icon": "Assets/icon.png", |
| "from": "Assets/co.nineapp.nine.appdata.xml", | ||
| "to": "usr/share/metainfo/co.nineapp.nine.appdata.xml" |
There was a problem hiding this comment.
Linux extraFiles references Assets/co.nineapp.nine.appdata.xml, but the repository contains 4-Nine/Assets/com.nineapp.nine.appdata.xml (different prefix/path). Electron-builder will fail to copy this file unless the filename/path is aligned.
| "from": "Assets/co.nineapp.nine.appdata.xml", | |
| "to": "usr/share/metainfo/co.nineapp.nine.appdata.xml" | |
| "from": "Assets/com.nineapp.nine.appdata.xml", | |
| "to": "usr/share/metainfo/com.nineapp.nine.appdata.xml" |
| <ElectronSingleInstance>false</ElectronSingleInstance> | ||
| <ElectronSplashScreen>wwwroot/assets/splash.png</ElectronSplashScreen> | ||
| <ElectronIcon>Assets/icon.png</ElectronIcon> | ||
| <ElectronPackageId>co.nineapp.nine</ElectronPackageId> |
There was a problem hiding this comment.
ElectronPackageId is set to co.nineapp.nine, but existing desktop metadata in the repo uses com.nineapp.nine (e.g., Assets/com.nineapp.nine.appdata.xml, and the added desktop-config.bk uses com.nineapp.nine). This inconsistency can break Linux metadata copying and app identity/update behavior; pick one identifier and make the configs/assets consistent.
| <ElectronPackageId>co.nineapp.nine</ElectronPackageId> | |
| <ElectronPackageId>com.nineapp.nine</ElectronPackageId> |
| { | ||
| app.Logger.LogWarning("Loading offline page due to backend unavailability"); | ||
| window.LoadURL($"{backendUrl}/offline.html"); | ||
| } |
There was a problem hiding this comment.
ElectronAppReady() never navigates to the main app when the backend health check succeeds. LoadURL() is only called for the offline page, so when isBackendReady is true the window will stay blank. Add an else branch (or unconditional default) to load the normal backendUrl (e.g., /) when the backend is healthy.
| } | |
| } | |
| else | |
| { | |
| app.Logger.LogInformation("Backend is ready, loading main application"); | |
| window.LoadURL(backendUrl); | |
| } |
Upgrade ElectronNET, fixed issues with application path, and added runtime identifiers.