Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of prerelease tags in normalizeWindowsVersion prevents app installed via MSI installer from starting on Windows #3805

Open
3 tasks done
marcinchwedczuk-asana opened this issue Jan 17, 2025 · 1 comment

Comments

@marcinchwedczuk-asana
Copy link

marcinchwedczuk-asana commented Jan 17, 2025

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:

Image

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).

@marcinchwedczuk-asana
Copy link
Author

PS. Looks like electron-wix-msi already supports "fixing" the version for MSI creation: https://github.com/electron-userland/electron-wix-msi/blob/3d476237f631380e2252027c4fde20eacccd438e/src/creator.ts#L205

I did a small test and just commented out the line:

    let { version } = packageJSON;
    if (version.includes('-')) {
      console.warn(
        logSymbols.warning,
        chalk.yellow('WARNING: WiX distributables do not handle prerelease information in the app version, removing it from the MSI')
      );
      // version = this.normalizeWindowsVersion(version); <- COMMENTED OUT
    }

This resulted in creation of an MSI with proper version (without prerelease tag).
The app directory:

Image

The application was properly starting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants