> ## 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.

# bach build: write the Setup.exe

> bach build [CONFIG]: packs your files and settings into one setup file. Flags: --out, --fast, --sign to sign it, --patch-from to also write an update patch.

`bach build` packs the files in `[files] source` and your settings into a single setup file, built on `bach-setup.exe`.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
bach build
bach build path/to/bach.toml --out dist/MySetup.exe
bach build --fast
```

| Argument or flag | Default | Meaning |
| - | - | - |
| `CONFIG` | `bach.toml` | The config file |
| `--out PATH`, `-o PATH` | `installer.output` | Write the setup file here instead |
| `--runtime PATH` | `bach-setup.exe` next to `bach` | The setup runtime to build on. Also read from the `BACH_RUNTIME` environment variable. |
| `--fast` | off | Compress quickly instead of as small as possible. Overrides `installer.compression` for this build. |
| `--online` | off | Also write the [online installer](/docs/reference/config/installer.md#online-and-offline-installers), same as `installer.online = true`. Needs `[updates]`. |
| `--key-file PATH` | none | Read the access key from this file (its first line) instead of the environment variable `[access]` names. Only for apps with [`[access]`](/docs/reference/config/access). |
| `--app-version VERSION` | `app.version` | Build with this version instead of `app.version`, so a release tag like `v1.4.0` is the only place the version is written. A leading `v` is dropped, and the output file name follows. |
| `--sign` | off | Sign every setup file the build writes with the program [`[signing]`](/docs/reference/config/signing) names. `BACH_SIGN=1` does the same. Without it nothing is signed and nothing runs. An error when there is no `[signing]`. |
| `--patch-from FILE` | none | An earlier setup file of this app. Also writes an [update patch](/docs/guides/updates.md#update-patches) from it, holding only the files that changed, and offers it in the feed when it is clearly smaller. |
| `--profile NAME` | none | Build this [profile](/docs/reference/config/profiles.md) instead of the main setup file. Repeat it for several. [`bach profiles`](/docs/reference/cli/profiles) lists them. |
| `--all-profiles` | off | Build the main setup file and every profile. Can't be combined with `--profile`. |
| `--runtime-arm64 PATH` | none | The ARM64 `bach-setup.exe` (from the ARM64 release) that [`[arch.arm64]`](/docs/reference/config/arch) builds on, when the config doesn't name one. Also read from `BACH_RUNTIME_ARM64`. |
| `--x64-only` | off | Build only the x64 setup file, even when `bach.toml` has `[arch.arm64]`. |
| `--msi` | off | Also write a Windows Installer package (`.msi`) of the app, for Group Policy, Configuration Manager and Intune. See [MSI packages](/docs/guides/msi.md). |
| `--strict` | off | Stop before building when `bach check` would warn, so no file is written. `BACH_STRICT=1` does the same. |

## Output

```console theme={"theme":{"light":"github-light","dark":"github-dark"}}
$ bach build
Wrote dist\Hello-Setup-1.0.0.exe (9.7 MB)
  Packed       101.8 KB of 216.5 KB (47%), in 0.9s
```

The default path is `dist/{name}-Setup-{version}.exe`. With `--online` (or `installer.online`), a second line reports the online installer, `dist/{name}-Web-Setup.exe`. With `--patch-from`, another line reports the patch, `dist/{name}-Setup-{version}-patch-from-{old version}.exe`, with how many files changed. An app with `[access]` prints `The files are encrypted with the access key.` and needs the key: see [`[access]`](/docs/reference/config/access). With an [`[updates]`](/docs/reference/config/updates) section that has `github` or a `download_url`, it also writes `latest.json` next to the setup file. With `github` set, the setup file is named the way GitHub serves a release download: anything but letters, digits, `.`, `-` and `_` in its name becomes `-`.

## Things to know

* Sign the setup file after the build, never before. Building writes into the file. With [`[signing]`](/docs/reference/config/signing) and `--sign`, `bach build` does this for you and signs before it writes the feed.
* Every build records each file's SHA-256 in the setup file, so a later [update patch](/docs/guides/updates.md#update-patches) can tell what changed. The first build of an app that updates is therefore a little slower.
* If the old setup file is open or the app is running from it, replacing it fails with a sentence asking you to close it. Close it and build again.
* On macOS and Linux the setup file keeps Bach's icon. Build on Windows to apply `app.icon`.
* Failure always ends with a non-zero exit code and a one-sentence reason, so it is safe in CI.

See [Preview and build](/docs/guides/preview-and-build.md) and [Automate in CI](/docs/guides/ci.md).


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