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

# Sign your setup file

> Why Windows warns about unsigned installers, how to sign a Bach setup file with signtool, let bach sign it for you, and verify the signature.

When someone downloads and runs an unsigned installer, Windows may show **Windows protected your PC** and call the publisher unknown. Code signing attaches your identity to the file. This page explains what you need and how to sign with Bach.

## What signing does

A code-signing certificate, bought from a certificate authority or a signing service, proves who published a file and that it hasn't changed since. Windows then shows your name instead of "Unknown publisher". New certificates can still get the SmartScreen warning at first, until the file or publisher has built up a reputation.

You don't need a certificate to build or test with Bach. You'll probably want one before you share your installer widely.

## Get signtool

Microsoft's `signtool` comes with the Windows SDK. Install the SDK with **Windows SDK Signing Tools for Desktop Apps** ticked. It usually isn't on your `PATH`; open **Developer PowerShell for VS**, or find it:

```powershell theme={"theme":{"light":"github-light","dark":"github-dark"}}
Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\bin" -Directory
```

`signtool.exe` is in the `x64` folder under the version number. Your certificate must be in the Windows certificate store, on a hardware token, or in a file you tell signtool about.

## Let Bach sign (recommended)

Add a `[signing]` section that says how your certificate is found:

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[signing]
arguments = 'sign /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 /a'
```

`/a` lets signtool pick the best certificate. Then build with `--sign`:

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

Bach signs every setup file it writes, including an online installer or update patch, before it writes the update feed. If signing fails, the build fails. Bach finds `signtool` in the Windows SDK by itself.

A few details:

* Signing only runs when you ask, with `--sign` or the environment variable `BACH_SIGN=1`. A `bach.toml` from someone else could name any program, so Bach never runs it just because you built.
* For signtool, `arguments` must start with `sign`.
* Use `program` for another signing tool, and `{env:NAME}` in the arguments for secrets, so they don't end up in the file. See [`[signing]`](/docs/reference/config/signing).
* `bach sign <file>` signs a file you built earlier.

## Or sign yourself

Sign **after** `bach build`, never before, because building writes into the file:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
signtool sign /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 /a "dist\Hello Notes-Setup-1.0.0.exe"
signtool verify /pa "dist\Hello Notes-Setup-1.0.0.exe"
```

If your app uses `[updates]`, write the feed again afterwards, because signing changed the file:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
bach feed "dist\Hello Notes-Setup-1.0.0.exe"
```

## Sign your programs too

Signing the setup file doesn't sign the `.exe` and `.dll` files inside it. Windows 11's Smart App Control checks every program that starts, so sign your own files in your build, before Bach packs them. With `[signing]` set, `bach check` warns about unsigned programs and names the first few.

## The uninstaller isn't signed

The `uninstall.exe` on your users' computers is written during install without a signature, because a signature only matches the exact file it was made for.

## Require signed updates

Installed apps can refuse updates that aren't signed by you. See [Protect your updates](/docs/guides/update-security.md#require-your-code-signature).

## Sign the macOS Setup app

If your `bach.toml` has a [`[macos]`](/docs/reference/config/macos) section, `bach build --sign` on a Mac signs the Setup app and the `.dmg` with Apple's `codesign`. Say which certificate to use:

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[macos.signing]
identity = "Developer ID Application: Example Inc. (ABCDE12345)"
notarize = "example-notary"
```

With `notarize`, the build also sends the `.dmg` to Apple to be checked (notarization) and attaches the result, so the app opens without a warning. For a `.pkg`, set `installer_identity` as well. Without `--sign`, the app is signed "ad hoc": it runs, but a downloaded copy asks the user to confirm the first time it opens. With `[updates] signer`, installed Mac apps only accept updates signed with a Developer ID Application certificate that Apple issued, with that name. Since Bach 0.11.3, `bach build --sign` stops if your certificate isn't one of these, and a Mac build without `--sign` warns that installed copies will refuse it. [Ship for macOS](/docs/guides/macos.md#sign-and-notarize) has the steps.

## Check a Bach download

Bach's own releases come with GitHub build attestations. To check that a download was built by Bach's release workflow:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
gh attestation verify bach-0.11.1-windows-x64.zip --repo usebach/bach-installer
```

Each release also lists the libraries in `bach` and `bach-setup.exe` as CycloneDX files.


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