Windows Installer
Ce contenu n’est pas encore disponible dans votre langue.
Tauri applications for Windows are either distributed as Microsoft Installers (.msi
files) using the WiX Toolset v3
or as setup executables (-setup.exe
files) using NSIS.
Please note that .msi
installers can only be created on Windows as cross-compilation doesn’t work.
Cross-compilation for NSIS installers is currently experimental.
This guide provides information about available customization options for the installer.
Building
To build and bundle your app into a Windows installer you can use the Tauri CLI and run the tauri build
command in a Windows computer:
Experimental: Build Windows apps on Linux and macOS
Cross compiling Windows apps on Linux and macOS hosts is possible when using NSIS. Note that this is currently considered highly experimental and may not work on every system or for every project. Therefore it should only be used as a last resort if local VMs or CI solutions like GitHub Actions don’t work for you.
Since Tauri officially only supports the MSVC Windows target, the setup is a bit more involved.
Install NSIS
Some Linux distributions have NSIS available in their repositories, for example on Ubuntu you can install NSIS by running this command:
But on many other distributions you have to compile NSIS yourself or download Stubs and Plugins manually that weren’t included in the distro’s binary package. Fedora for example only provides the binary but not the Stubs and Plugins:
On macOS you will need [Homebrew] to install NSIS:
Install LLVM and the LLD Linker
Since the default Microsoft linker only works on Windows we will also need to install a new linker.
To compile the Windows Resource file which is used for setting the app icon among other things
we will also need the llvm-rc
binary which is part of the LLVM project.
On Linux you also need to install the clang
package if you added dependencies that compile C/C++ dependencies as part of their build scripts.
Default Tauri apps should not require this.
On macOS you also have to add /opt/homebrew/opt/llvm/bin
to your $PATH
as suggested in the install output.
Install the Windows Rust target
Assuming you’re building for 64-bit Windows systems:
Install cargo-xwin
Instead of setting the Windows SDKs up manually we will use [cargo-xwin
] as Tauri’s “runner”:
By default cargo-xwin
will download the Windows SDKs into a project-local folder.
If you have multiple projects and want to share those files you can set the XWIN_CACHE_DIR
environment variable with a path to the preferred location.
Building the App
Now it should be as simple as adding the runner and target to the tauri build
command:
The build output will then be in target/x86_64-pc-windows-msvc/release/bundle/nsis/
.
Building for 32-bit or ARM
The Tauri CLI compiles your executable using your machine’s architecture by default. Assuming that you’re developing on a 64-bit machine, the CLI will produce 64-bit applications.
If you need to support 32-bit machines, you can compile your application with a different Rust target
using the --target
flag:
By default, Rust only installs toolchains for your machine’s target,
so you need to install the 32-bit Windows toolchain first: rustup target add i686-pc-windows-msvc
.
If you need to build for ARM64 you first need to install additional build tools.
To do this, open Visual Studio Installer
, click on “Modify”, and in the “Individual Components” tab install the “C++ ARM64 build tools”.
At the time of writing, the exact name in VS2022 is MSVC v143 - VS 2022 C++ ARM64 build tools (Latest)
.
Now you can add the rust target with rustup target add aarch64-pc-windows-msvc
and then use the above-mentioned method to compile your app:
Note that the NSIS installer itself will still be x86 running on the ARM machine via emulation. The app itself will be a native ARM64 binary.
Supporting Windows 7
By default, the Microsoft Installer (.msi
) does not work on Windows 7 because it needs to download the WebView2 bootstrapper if not installed
(which might fail if TLS 1.2 is not enabled in the operating system). Tauri includes an option to embed the WebView2 bootstrapper
(see the Embedding the WebView2 Bootstrapper section below).
The NSIS based installer (-setup.exe
) also supports the downloadBootstrapper
mode on Windows 7.
Additionally, to use the Notification API in Windows 7, you need to enable the windows7-compat
Cargo feature:
FIPS Compliance
If your system requires the MSI bundle to be FIPS compliant you can set the TAURI_FIPS_COMPLIANT
environment variable to true
before running tauri build
. In PowerShell you can set it for the current terminal session like this:
WebView2 Installation Options
The installers by default download the WebView2 bootstrapper and executes it if the runtime is not installed. Alternatively, you can embed the bootstrapper, embed the offline installer, or use a fixed WebView2 runtime version. See the following table for a comparison between these methods:
Installation Method | Requires Internet Connection? | Additional Installer Size | Notes |
---|---|---|---|
downloadBootstrapper | Yes | 0MB | Default Results in a smaller installer size, but is not recommended for Windows 7 deployment via .msi files. |
embedBootstrapper | Yes | ~1.8MB | Better support on Windows 7 for .msi installers. |
offlineInstaller | No | ~127MB | Embeds WebView2 installer. Recommended for offline environments. |
fixedVersion | No | ~180MB | Embeds a fixed WebView2 version. |
skip | No | 0MB | ⚠️ Not recommended Does not install the WebView2 as part of the Windows Installer. |
On Windows 10 (April 2018 release or later) and Windows 11, the WebView2 runtime is distributed as part of the operating system.
Downloaded Bootstrapper
This is the default setting for building the Windows Installer. It downloads the bootstrapper and runs it.
Requires an internet connection but results in a smaller installer size.
This is not recommended if you’re going to be distributing to Windows 7 via .msi
installers.
Embedded Bootstrapper
To embed the WebView2 Bootstrapper, set the webviewInstallMode to embedBootstrapper
.
This increases the installer size by around 1.8MB, but increases compatibility with Windows 7 systems.
Offline Installer
To embed the WebView2 Bootstrapper, set the webviewInstallMode to offlineInstaller
.
This increases the installer size by around 127MB, but allows your application to be installed even if an internet connection is not available.
Fixed Version
Using the runtime provided by the system is great for security as the webview vulnerability patches are managed by Windows. If you want to control the WebView2 distribution on each of your applications (either to manage the release patches yourself or distribute applications on environments where an internet connection might not be available) Tauri can bundle the runtime files for you.
- Download the WebView2 fixed version runtime from Microsoft’s website.
In this example, the downloaded filename is
Microsoft.WebView2.FixedVersionRuntime.128.0.2739.42.x64.cab
- Extract the file to the core folder:
- Configure the WebView2 runtime path in
tauri.conf.json
:
- Run
tauri build
to produce the Windows Installer with the fixed WebView2 runtime.
Skipping Installation
You can remove the WebView2 Runtime download check from the installer by setting webviewInstallMode to skip
.
Your application WILL NOT work if the user does not have the runtime installed.
Your application WILL NOT work if the user does not have the runtime installed and won’t attempt to install it.
Customizing the WiX Installer
See the WiX configuration for the complete list of customization options.
Installer Template
The .msi
Windows Installer package is built using the WiX Toolset v3.
Currently, apart from pre-defined configurations, you can change it by using a custom WiX source code
(an XML file with a .wxs
file extension) or through WiX fragments.
Replacing the Installer Code with a Custom WiX File
The Windows Installer XML defined by Tauri is configured to work for the common use case
of simple webview-based applications (you can find it here).
It uses handlebars so the Tauri CLI can brand your installer according to your tauri.conf.json
definition.
If you need a completely different installer, a custom template file can be configured on tauri.bundle.windows.wix.template
.
Extending the Installer with WiX Fragments
A WiX fragment is a container where you can configure almost everything offered by WiX. In this example, we will define a fragment that writes two registry entries:
Save the fragment file with the .wxs
extension in the src-tauri/windows/fragments
folder and reference it on tauri.conf.json
:
Note that ComponentGroup
, Component
, FeatureGroup
, Feature
and Merge
element ids must be referenced on the wix
object
of tauri.conf.json
on the componentGroupRefs
, componentRefs
, featureGroupRefs
, featureRefs
and mergeRefs
respectively to be included in the installer.
Internationalization
The WiX Installer is built using the en-US
language by default.
Internationalization (i18n) can be configured using the tauri.bundle.windows.wix.language
property,
defining the languages Tauri should build an installer against.
You can find the language names to use in the Language-Culture column on Microsoft’s website.
Compiling a WiX Installer for a Single Language
To create a single installer targeting a specific language, set the language
value to a string:
Compiling a WiX Installer for Each Language in a List
To compile an installer targeting a list of languages, use an array. A specific installer for each language will be created, with the language key as a suffix:
Configuring the WiX Installer Strings for Each Language
A configuration object can be defined for each language to configure localization strings:
The localePath
property defines the path to a language file, a XML configuring the language culture:
Currently, Tauri references the following locale strings: LaunchApp
, DowngradeErrorMessage
, PathEnvVarFeature
and InstallAppFeature
.
You can define your own strings and reference them on your custom template or fragments with "!(loc.TheStringId)"
.
See the WiX localization documentation for more information.
Customizing the NSIS Installer
See the NSIS configuration for the complete list of customization options.
Installer Template
The NSIS Installer’s .nsi
script defined by Tauri is configured to work for the common use case
of simple webview-based applications (you can find it here).
It uses handlebars so the Tauri CLI can brand your installer according to your tauri.conf.json
definition.
If you need a completely different installer, a custom template file can be configured on tauri.bundle.windows.nsis.template
.
Extending the Installer
If you only need to extend some installation steps you might be able to use installer hooks instead of replacing the entire installer template.
Supported hooks are:
NSIS_HOOK_PREINSTALL
: Runs before copying files, setting registry key values and creating shortcuts.NSIS_HOOK_POSTINSTALL
: Runs after the installer has finished copying all files, setting the registry keys and created shortcuts.NSIS_HOOK_PREUNINSTALL
: Runs before removing any files, registry keys and shortcuts.NSIS_HOOK_POSTUNINSTALL
: Runs after files, registry keys and shortcuts have been removed.
For example, create a hooks.nsi
file in the src-tauri/windows
folder and define the hooks you need:
Then you must configure Tauri to use that hook file:
Install Modes
By default the installer will install your application for the current user only.
The advantage of this option is that the installer does not require Administrator privileges to run,
but the app is installed in the %LOCALAPPDATA%
folder instead of C:/Program Files
.
If you prefer your app installation to be available system-wide (which requires Administrator privileges)
you can set installMode to perMachine
:
Alternatively you can let the user choose whether the app should be installed for the current user only or system-wide
by setting the installMode to both
.
Note that the installer will require Administrator privileges to execute.
See NSISInstallerMode for more information.
Internationalization
The NSIS Installer is a multi-language installer, which means you always have a single installer which contains all the selected translations.
You can specify which languages to include using the tauri.bundle.windows.nsis.languages
property.
A list of languages supported by NSIS is available in the NSIS GitHub project.
There are a few Tauri-specific translations required, so if you see untranslated texts feel free to open a feature request in Tauri’s main repo.
You can also provide custom translation files.
By default the operating system default language is used to determine the installer language. You can also configure the installer to display a language selector before the installer contents are rendered:
Minimum Webview2 version
If your app requires features only available in newer Webview2 versions (such as custom URI schemes), you can instruct the Windows installer to verify the current Webview2 version and run the Webview2 bootstrapper if it does not match the target version.
© 2024 Tauri Contributors. CC-BY / MIT