> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Bach builds Windows installers from one bach.toml with the bach command: bach init, bach check, bach preview, bach build. Installs are per user and need no administrator rights by default. installer.scope = "machine" installs for every user after one Windows prompt. On Windows, run setup files with Start-Process -Wait -PassThru in PowerShell, and give signtool arguments that start with the word sign.

# Package an Electron app

> Turn the unpacked output of electron-builder or Electron Forge into a Setup.exe with Bach: build the folder, write bach.toml, check and build.

This guide turns an Electron app into a Bach setup file. You keep using your Electron tool to build the app; Bach takes the unpacked app folder it produces and makes the installer.

## 1. Build the unpacked app

Bach needs the app as a folder of files, not an installer made by your Electron tool.

> [tab] electron-builder
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
> npx electron-builder --win --dir
> ```
>
> This writes the app to `dist/win-unpacked`.

> [tab] Electron Forge
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
> npx electron-forge package
> ```
>
> This writes the app to a folder such as `out/Notes-win32-x64`.

Start the `.exe` in that folder once, to check the app works before you package it.

## 2. Create bach.toml

Run this next to your `package.json`:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
bach init
```

Bach reads `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):

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[app]
name = "Notes"
version = "2.0.0"
publisher = "Your Company"
executable = "Notes.exe"

[files]
source = "dist/win-unpacked"
exclude = ["*.pdb", "*.log", "Thumbs.db", ".DS_Store"]
```

Check two values, because they're guesses:

* `executable` must be the name of the `.exe` inside the folder.
* `source` must be the folder you built in step 1.

If your project is a GitHub repository, `bach init` also turns on automatic updates and adds a release workflow. Read [Automatic updates](/docs/guides/automatic-updates.md) before you ship, or delete the `[updates]` section if you don't want them.

## 3. Check and build

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
bach check
bach preview
bach 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`.

> [!WARNING]
>
> electron-builder also uses `dist/` for its output. Bach puts its setup file in `dist/` too, but only packages what's inside `files.source`, so the two don't mix. If your `source` is `dist` itself, change `installer.output` to another folder.

## Add your icon

Bach doesn't take the icon from your Electron config. Point it at your `.ico` file:

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[app]
name = "Notes"
version = "2.0.0"
publisher = "Your Company"
executable = "Notes.exe"
icon = "build/icon.ico"
```

The icon appears on the setup file and in the install window. The icon of the installed app itself comes from your Electron build, as before.

## Things that differ from electron-builder's installer

* **Updates.** `electron-updater` doesn't know how to install a Bach setup file. If you use it, turn it off and use [Bach's updates](/docs/guides/automatic-updates.md) 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](/docs/guides/migrate-from-another-installer.md) so they don't end up with two copies.
* **Links and file types.** Register them with [`[[protocols]]` and `[[file_types]]`](/docs/guides/integration), 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, and `bach 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`.

## Next steps

* [Customize the install window](/docs/guides/customize-the-window.md)
* [Ship an update](/docs/guides/first-update.md)
* [Sign your setup file](/docs/guides/signing.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.