1. Build the unpacked app
Bach needs the app as a folder of files, not an installer made by your Electron tool.- electron-builder
- Electron Forge
dist/win-unpacked..exe in that folder once, to check the app works before you package it.
2. Create bach.toml
Run this next to yourpackage.json:
package.json and fills in the name (productName, or the package name), the version, the author as publisher, the program name and the build folder. A result for an app called Notes looks like this (without the commented-out options):
bach.toml
executablemust be the name of the.exeinside the folder.sourcemust be the folder you built in step 1.
bach init also turns on automatic updates and adds a release workflow. Read Automatic updates before you ship, or delete the [updates] section if you don’t want them.
3. Check and build
bach check lists every file that will be installed. Look through it for anything that shouldn’t ship. bach build writes dist/Notes-Setup-2.0.0.exe.
Add your icon
Bach doesn’t take the icon from your Electron config. Point it at your.ico file:
bach.toml
Things that differ from electron-builder’s installer
- Updates.
electron-updaterdoesn’t know how to install a Bach setup file. If you use it, turn it off and use Bach’s updates instead. - Install location. Bach installs to
%LOCALAPPDATA%\Programs\<name>by default. If your users already have the app from another installer, add a migration step so they don’t end up with two copies. - Links and file types. Register them with
[[protocols]]and[[file_types]], not from your app on first start.
Keep the file list small
Electron apps can contain thousands of small files. Bach stores the list of files in the setup file and in the uninstaller, andbach check warns when that list gets large. Package your app code into an asar archive (both tools can do this) and leave out tests, documentation and source maps with files.exclude.