Build a Windows installer
winbridge package turns the files from winbridge build into a single Windows setup program. This page covers the default installer, your own installer script, and signing.
What the installer does
An installer is the setup.exe a Windows user double-clicks. The one WinBridge generates:
- installs your app into Program Files,
- adds a Start Menu shortcut,
- adds an entry under Add or Remove Programs,
- includes an uninstaller.
WinBridge builds it with NSIS, a widely used open-source installer system. NSIS is a Windows program, so WinBridge runs it under the same managed Wine runtime that winbridge run uses. You install neither yourself: both are downloaded on first use (NSIS is 2 MB, the Wine runtime about 94 MB).
Build an installer
Build the project first.
bashwinbridge build ./myappPackage it, giving the version number to record in the installer.
bashwinbridge package ./myapp --app-version 1.2.3Find the installer next to the build output:
myapp/build/winbridge/windows-x64/myapp-1.2.3-setup.exe.
Every file directly in the build output folder goes into the installer, except installers and .nsi scripts left by earlier packaging runs. Subfolders are not included. The Start Menu shortcut points at the .exe named after the project; if there is none with that name, it points at the first .exe by name.
Without --app-version, the version is 0.0.0.
Good to know
The setup program itself is a 32-bit Windows executable, so it starts on any Windows version whatever the app inside it is. That is NSIS's normal behaviour.
Options
| Option | What it does | Default |
|---|---|---|
--artifacts | Folder that holds the built files. | build/winbridge/windows-x64 in the project |
-o, --output | Installer file to write. | <app>-<version>-setup.exe in the artifacts folder |
--app-version | Version recorded in the installer. | 0.0.0 |
--script | Your own NSIS script, used instead of the generated one. | None |
--sign | A PKCS#12 certificate (.pfx) to sign the installer with. | None |
Use your own installer script
WinBridge writes the NSIS script it generates next to the build output on every run. To change what the installer does, copy that .nsi file somewhere else, edit the copy, and pass it with --script:
winbridge package ./myapp --script installer/myapp.nsi -o dist/setup.exeEdit a copy, not the generated file: WinBridge overwrites the generated one each time.
Sign the installer
Windows warns users about programs from an unknown publisher. Authenticode signing attaches your publisher identity to the installer with a code-signing certificate, which you obtain from a certificate authority.
Install
osslsigncode. WinBridge does not download it. On Debian and Ubuntu:bashsudo apt install osslsigncodePut the certificate passphrase in the
WINBRIDGE_SIGN_PASSPHRASEenvironment variable. Typingread -rsfirst keeps it off the screen and out of your shell history:bashread -rs WINBRIDGE_SIGN_PASSPHRASE export WINBRIDGE_SIGN_PASSPHRASEPackage with
--signand the path to your.pfxfile.bashwinbridge package ./myapp --app-version 1.2.3 --sign certs/app.pfx
If the variable is not set, osslsigncode asks for the passphrase itself. There is no command-line option for the passphrase, on purpose: anything on a command line can be read by other processes on the machine.
Signatures are timestamped through a public timestamp server, so they stay valid after the certificate expires. Signing therefore needs an internet connection.
If osslsigncode is missing, --sign fails with a message saying so. WinBridge does not leave you with an installer you believe is signed when it is not.
DANGER
A .pfx file and its passphrase are your publisher identity. Keep the certificate out of your source repository and never put the passphrase in a script that is committed or shared.
Limits
- Installers are NSIS
.exefiles. MSI packages are not supported. - The generated installer packs only the files at the top of the build output folder. An app that needs subfolders, such as the
datafolder of a Flutter app, needs your own NSIS script. - The WinBridge project's tests cover how the signing command is built, not signing against a real certificate authority. Check the signature on Windows (file Properties, Digital Signatures tab) before you publish.
Next steps
- Run Windows programs to try the installer on Linux
- Command reference
- Troubleshooting and FAQ