An MVP for a simple and modern "one click" windows installer for Tauri apps.
This work is heavily inspired by VeloPack and uses many of the same concepts, however unlike VeloPack this work only handles the install and uninstall of Tauri applications, only on Windows, and has no support for any update mechanisms.
- Simple installer - Small file size and code complexity
- Opinionated implementation - Lack of features is the main feature
- One click installs - No wizards, just install and launch the app immediately
While this implementation is standalone and could be used with any Tauri projects, the end goal is to have this work (or something based on it) merged into the Tauri core as a built-in option for bundling on windows.
Windows Version | 64-bit | 32-bit |
---|---|---|
Windows 11 | ✅ | ❌ |
Windows 10 | ✅ | ❌ |
Windows 8 | ❌ | ❌ |
Windows 7 | ❌ | ❌ |
Tauri apps on Windows require WebView2 which is included with Windows 10 20H2 and later versions.
Windows 10 versions earlier than 20H2, the WebView2 Evergreen Bootstrapper (~1.6MB) can be bundled in to the setup executable. If WebView2 is not detected, if present the bootstrapper will be run, to streamline downloading and installation of WebView2 as part of the installation process. The offline installers (~155MB) could be included in the future if required.
Only 64-bit Windows is supported and tested. Windows 11 only supports 64-bit and online market data reports suggest Windows 10 32-bit usage is under 1% of all Windows 10 installs.
Windows 8 and earlier may work, but are not explicitly supported right now.
# Build all libraries and setup.exe
cargo build --release
cp .\target\release\setup.exe .\bundler\
# Install the bundler application
cargo build --package twi_bundler --release
cargo install --path bundler
# Build the demo Tauri app
cd .\demo-app\; pnpm tauri build; cd ..\
# Bundle the demo app into an installer
bundler.exe --tauri-conf '.\demo-app\src-tauri\tauri.conf.json' --app '.\target\release\demo-app.exe' --title 'Demo App'
The output from the bundler should look similar to this:
Packaging Tauri application...
Loading config: .\demo-app\src-tauri\tauri.conf.json
Loaded setup executable: setup.exe (667.1 KB bytes)
Bundling the webview2 evergreen bootstrapper...
Downloading WebView2 Evergreen: https://go.microsoft.com/fwlink/p/?LinkId=2124703
Loaded WebView2 Evergreen: MicrosoftEdgeWebview2Setup.exe (1.6 MB bytes)
Loaded application executable: demo-app.exe (10.1 MB bytes)
Packaging complete.
Created demo-app-setup.exe (12.4 MB)
Tauri Windows Installer Bundler
Usage: bundler.exe --tauri-conf <TAURI_CONF> --app <APP>
Options:
-t, --tauri-conf <TAURI_CONF> Path to the Tauri configuration file
-a, --app <APP> Path to application to bundle
-t, --title <TITLE> Title of the bundled application
-h, --help Print help
-V, --version Print version
The bundler is used to construct a custom setup executable for installing the Tauri application on the host system.
The base setup.exe
file is included in the bundler with the rust include_bytes!()
. The bundler then uses that built in binary as a base to append a setup manifest, webview2 installer (if required) and the application.
The installer crate builds both a skeleton setup application (setup.exe
) along with a library tauri_windows_installer
:
- The setup application is what's used by the bundler as a base for the final setup executable.
- The library is used by the target Tauri app to add a
--uninstall
hook to the application, to handle uninstalling the app.
- The bundled package is extracted, this contains a setup manifest and all the bundled files
- If WebView2 is not installed and the boostrapper is included, the boostrapper executable will be written to disk and spawned
- The installation directory is determined, defaulting to
%APPDATA%\{app-identifier}
- If the installation directory doesn't exist, it's created, if it does exist and the target application executable exists inside, a dialog is shown prompting to overwrite or cancel the installation
- When overwriting, the existing installation directory is moved to a temporary location
- The installation directory is emptied
- The application is installed. This copies the application to the installation directory and spawns it as a detached process
- If the previous step failed and an existing installation is being overwritten, a rollback occurs by renaming the temporary installation back to it's original name. The setup process then exits
- An uninstall entry is written to the the
HKEY_CURRENT_USER
registry, using{productName}.exe --uninstall
as the uninstall command
The uninstaller is built into the main Tauri application, by calling a function from the tauri_windows_installer
library. This adds a --uninstall
argument handler to the Tauri application
tauri_windows_installer::handle_uninstall(&"{app_title}", &"{app_id}");
- Kill all running application processes
- Remove the installation directory (except for the application executable)
- Remove the entry from the
HKEY_CURRENT_USER
registry - Show a dialog box with the result of the uninstall
- Spawn a separate process to delete the installation directory
- Bundler
-
Add-s, --setup-version
arguments to print the currently built-insetup.exe
version - Add an icon to the packaged
{productName}-setup.exe
- Add other resource information like name, version, date etc to the
{productName}-setup.exe
- Get a human friendly application title from somewhere (cli argument?)
-
- Installer
- Embed versioning into
setup.exe
- Check the OS version and architecture
- Improve the required space calculation
- Get publisher from somewhere for uninstall registry entry
- Embed versioning into
- Other
- Setup GitHub Actions to build and release
- Investigate using libsui to replace custom bundling code