[updates] can’t update itself later; its user has to run a newer setup file once.
1. Say where updates come from
If your code is on GitHub and the repository is public:bach.toml
https host:
bach.toml
feed is the address of the update feed. download_url is where the setup file will be, with {file} replaced by its name. Where to host updates walks through both.
Your version must be numbers with dots, such as 1.2.0, so Bach can compare versions.
2. Build and publish
latest.json:
latest.json
latest.json. If you sign the setup file after building, write the feed again with bach feed, because signing changes the file.
What the user sees
The install window has an extra box, Automatic updates, ticked. If the user leaves it ticked, setup creates a Windows scheduled task for their account that checks for updates every four hours, and soon after the computer is turned on again if a check was missed. It runs hidden and needs no administrator rights. Each check:- reads the feed
- downloads a newer version, if there is one
- installs it, but only if your app isn’t running; otherwise it waits for a later check
Change the default
bach.toml
Apps that install for every user can’t update in the background, because a normal user can’t write to Program Files. Leave
auto out for them.
Check for updates from your app
The installeduninstall.exe also handles updates. Your app can run it:
--json prints one line with app, current, latest, available, downloaded, notes and size.
uninstall.exe is in your app’s install folder, next to your program.
Update when the user quits
A common pattern:- When your app starts, run
uninstall.exe --download-updatein the background. - When the user quits, or clicks “Restart to update”, start this and exit:
--wait-for waits for your app to close, and --launch starts it again after updating. The download already happened while the app was open, so the update itself takes a moment.
To try the commands in PowerShell, use Start-Process, which waits and gives you the exit code:
Interrupted updates
- If the download stops, it continues where it left off next time.
- If a file is held for a moment, for example by a virus scanner right after your app closes,
--apply-updatetries three times, then keeps the download for later. - If the computer shuts down during an update, the next check or setup puts the old files back first.
When something goes wrong
Every update run writes%TEMP%\<app id>-update.log. Why aren’t automatic updates working? goes through the usual causes.