Electron-builder: Ability to skip uninstallOldVersion macro (NSIS)

Created on 8 Mar 2018  Â·  9Comments  Â·  Source: electron-userland/electron-builder


  • Version: 20.2.0

  • Target: win32, win64


Currently I'm working in an application that uses a custom autoupdater inside the app. It's a game launcher, so, sometimes you might want to download a newer version of the launcher but keep your old files as well (as the game is downloaded in the same folder).

The issue is that every new installation erases the entire destination folder prior to installing. I'd like to have an option to just replace without clearing everything up beforehand, so, the uninstallOldVersion should be toggleable.

I tried to remove the macros in installer.nsi and installSection.nsh but electron-builder just throws a warning treated as an error, so I can't do this without setting warningsAsErrors as false. However, this requires me to remove lines 49-52 from installSection.nsh, and I have to do this everytime I recreate the node_modules folder.

Any help would be greatly appreciated.

question

All 9 comments

PR welcome :)

as the game is downloaded in the same folder

It is is strictly forbidden and not allowed. Not recommended — please do not modify app installation dir, instead, write data to user data dir.

Well that might be how you want electron-builder to work or how you think installer apps should behave. In the outside world though, it doesn't work like this. I decided to keep editing the InstallSection.nsh instead. This way my users are happy and my app works like other apps normally do (Battle.NET Launcher, Epic Launcher, Origin, etc...). It's sad that you think that way and closed the issue instead of giving choice to your end users. I guess choice in most OSS projects is forking them then...

@darkguy2008 Is is common practice to not write into app dir. Issue is closed — but it doesn't mean that your PR will be rejected. I have limited free time and "issue closed" means "I don't have time to implement this rare case". As you can see, label "won't fix" is not added and conversation is not locked (you can comment).

Oh, alright, I had taken it as a plain "wont-fix" case like I've seen in most big OSS projects :| sorry for the harsh language then. Still when it comes to games they write everything where the installer output is located, just take a look at the examples I've described. It's okay, I can work in a PR then and hopefully it'll give other users more choice :) thanks!

Problem — how to remove outdated application files. I mean — if new Electron version will remove some file (will be merged into another or just removed) and your new app version will not have such file. So, if just install over — outdated files will be still in the app dir.

See http://nsis.sourceforge.net/Uninstall_only_installed_files But this approach was not implemented (decided for simplicity and security.)

@develar that's right, it's a case that will happen in my case and for my users, but it's a workaround as what I actually expected was electron-builder to remove the installed files (as your link describes) instead of deleting the entire folder.

I was also looking for a way to do that through one of the macros that can be run before or after the install steps, but I couldn't find a way to inject my macro (similar to the one you've shared) right after I get the filelist without heavy modification of the NSH script.

I think this could be an opportunity for improvement instead. If you can generate the filelist automatically when creating the package (I haven't seen much of the source code yet, I'm assuming here) you can also specify them in the uninstall/reinstall process instead of deleting the whole folder altogether. When it comes to games, they aren't usually installed in any data dir, most people have a separate drive and chose it for their games. I agree that it will work for apps, but not much for games.

@darkguy2008 facing the same problem here, any updates? I can try helping with the PR.

Was this page helpful?
0 / 5 - 0 ratings