How to handle app update to another name in Electron?

20 Views Asked by At

I am developing an app in electron (electronforge) + react.js which can be installed via msi (created by @electron-forge/maker-wix). Installer by default creates a shortcut on user
desktop. All updates are handled by autoUpdater module from electron and all was working fine until now.

I had to re-skin an app (changed logo, app name etc.)

Normally the update process looked like this:

  • uploading app with bumped version to update server (.nupkg + RELEASES file)
  • autoUpdater handles update
  • app is restarting, and new update is installed

But after re-sking, update process does not re-launch an app, desktop shortcut remains the same, and it's not working anymore. In app folder new .exe file is added - and after launching it app is starting to work.

My first thought was to force the users to reinstall the application, but this is just silly.

The question is: How should i handle this case? How can i make electron to launch .exe with new name after updating? Should i create desktop icons/and remove old .exe from system manually?

For now i tried to run code found here (https://github.com/electron/windows-installer/blob/0336cc646af849f125979ba623efdf5440852c4e/README.md#handling-squirrel-events) whenever i detect that user is updating from version with old name to version with new name:

switch (squirrelEvent) {
  case '--squirrel-obsolete':
    // This is called on the outgoing version of your app before
    // we update to the new version - it's the opposite of
    // --squirrel-updated
    spawnUpdate(['--createShortcut', newExeName]);
    spawnUpdate(['--removeShortcut', oldExeName]);
    return true;

But it gives me a error that both --createShortcut and --removeShortcut is not supported in Msi squirrel.

i also tried to force app to quit after update by

import { spawn } from 'child_process';

autoUpdater.on('update-downloaded', () => {
  spawn(`${path}/${newAppName}.exe');
  app.quit();
});

but it gives me NOENT error, which simply means that new exe file is not created yet - and it looks like more hacky way.

Do you guys have any ideas, or knowledge how to handle it?

0

There are 0 best solutions below