> ## 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 a Rust app

> Make a Setup.exe for a Rust program with Bach: build in release mode, clean up target/release, handle the Visual C++ runtime and build the installer.

This guide makes a setup file for a program built with Cargo, whether it's a desktop app or a command-line tool.

## 1. Build in release mode

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
cargo build --release
```

Your program is in `target/release`.

## 2. Create bach.toml

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

Bach reads `Cargo.toml` for the name, version, first author and program name. For a package called `note-pad` you get (without the commented-out options):

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[app]
name = "Note Pad"
version = "0.3.1"
publisher = "Jane Doe"
executable = "note-pad.exe"

[files]
source = "target/release"
exclude = ["*.pdb", "*.log", "Thumbs.db", ".DS_Store", "*.d", "*.rlib", "build/**", "deps/**", "incremental/**", ".fingerprint/**", "examples/**", "bundle/**"]
```

If your version comes from a workspace (`version.workspace = true`), Bach can't read it and writes `1.0.0`. Set it yourself, or pass it at build time with `bach build --app-version 0.3.1`.

## Use a clean folder instead (recommended)

`target/release` can hold other programs from the same workspace, test files and leftovers from earlier builds. A folder with only what you ship is safer:

```powershell theme={"theme":{"light":"github-light","dark":"github-dark"}}
New-Item -ItemType Directory -Force dist\app | Out-Null
Copy-Item target\release\note-pad.exe dist\app\
```

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[files]
source = "dist/app"
```

Copy any assets your program loads at run time into the same folder.

## The Visual C++ runtime

Rust programs built for Windows with the default (MSVC) toolchain usually need the Visual C++ runtime (`vcruntime140.dll`). Many computers have it, some don't. You have two options.

Build the runtime into your program:

```toml .cargo/config.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
```

Or ask the installer to check for it:

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[[requirements]]
kind = "vcredist"
```

## Command-line tools

For a tool people type in a terminal, put it on `PATH` and skip the desktop shortcut:

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[installer]
add_to_path = "always"
desktop_shortcut = "never"
start_menu_shortcut = "never"
open_button = false
```

After installing, users can run `note-pad` from any new terminal window.

## 3. Check and build

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
bach check
bach preview
bach build
```

## Next steps

* [Windows integration](/docs/guides/integration.md)
* [One-click releases from GitHub](/docs/guides/releasing.md). `bach version` also updates `Cargo.toml` and `Cargo.lock`.
* [Sign your setup file](/docs/guides/signing.md)


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