Auto Updater Electron

Asked

Viewed 439 times

-1

I’m using Electron + VueJS, and would like to know how to implement the auto updater, I did a little research, but I didn’t get anything, to be honest, I didn’t understand how it works, where it downloads the update, these things.

2 answers

0

Implemented in an Angular project, but can help you.

I used the Electron-winstaller, after the procedure, three files are generated:

  • project-Version.full.nupkg
  • RELEASES
  • projectSetup.exe

The RELEASES file automatically controls the summers to be updated. If you update the system and perform the winstaller procedure, a new nupkg will be included and added in the final RELEASES file.

In main.js insert the following code:

const { autoUpdater } = require('electron');

autoUpdater.on('update-availabe', () => { });
autoUpdater.on('checking-for-update', () => { });
autoUpdater.on('update-not-available', () => { });
autoUpdater.on('update-downloaded', () => {
  autoUpdater.quitAndInstall();
});
autoUpdater.setFeedURL(__IP_DO_SERVIDOR__);
.
.
app.on('ready', () => {
  createBrowserWindow();
  try {
    autoUpdater.checkForUpdates();
  } catch (err) { }
});

The server only needs to contain the *.nupkg and RELEASE files generated in the build. I opened a server using the http-server. The autoUpdate module of Electron when opening the application, makes the requests to check if there is update, download, install and update automatically, for this, the server just be accessible.

Remembering that the application should be installed by the setup created by Electron.

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.