Removal of prerelease tags in normalizeWindowsVersion prevents app installed via MSI installer from starting on Windows #3805
Description
Pre-flight checklist
- I have read the contribution documentation for this project.
- I agree to follow the code of conduct that this project uses.
- I have searched the issue tracker for a bug that matches the one I want to file, without success.
Electron Forge version
7.6.0
Electron version
32.2.1
Operating system
Windows 11 ARM
Last known working Electron Forge version
No response
Expected behavior
The app should be able to start even if the prerelease tag was removed.
Actual behavior
When I use prerelease tag in the app version then the app installed via MSI installer does not start on Windows 11 (ARM).
Steps to reproduce
Add a prerelease tag to the application version:
package.json:
"version": "2.3.0-foobar",
Use @electron-forge/maker-wix
in forge.config.js
.
Create the installer: npx electron-forge make --platform=win32 --arch=arm64
There should be a warning printed during the forge execution:
WARNING: WiX distributables do not handle prerelease information in the app version, removing it from the MSI
Install the app in the system using the created MSI installer:
Notice that the app directory has suffix that is not a correct semver: 2.3.0.0
.
The application is not starting. There are crash reports in the system EventViewer. When I skip the wrapper exe and run app-2.3.0.0/Asana-text.exe
the application starts.
When we rename the directory from app-2.3.0.0
to app-2.3.0
the wrapper starts to work again.
Additional information
I think the problem is located in https://github.com/electron/forge/blob/7144376a309c37432d8375ebb65f2c1a8a1080f3/packages/maker/base/src/Maker.ts#L176C3-L176C26
normalizeWindowsVersion(version: string): string {
const noPrerelease = version.replace(/[-+].*/, '');
return `${noPrerelease}.0`;
}
The function should not append .0
when it is removing prerelase tag. Ideally we could use a semver library to remove the prerelase tag instead of a regex.
An alternative solution would be to change StubExecutable (https://github.com/Squirrel/Squirrel.Windows/blob/develop/src/StubExecutable/StubExecutable.cpp) to recognize non semver compliant versions. But this would result in a very ugly design. After all it's better to stick to semver everywhere.
As I understand (https://learn.microsoft.com/en-us/windows/win32/msi/productversion) MSI files support only versions in format major.minor.build
(I am not Windows expert).