UNPKG

10.4 kBMarkdownView Raw
1![electron-wix-msi](.github/logo.png)
2
3[![Build status](https://ci.appveyor.com/api/projects/status/s54pty8rve3yemb9?svg=true)](https://ci.appveyor.com/project/felixrieseberg/electron-wix-msi)
4[![Build Status](https://travis-ci.org/felixrieseberg/electron-wix-msi.svg?branch=master)](https://travis-ci.org/felixrieseberg/electron-wix-msi)
5[![Coverage Status](https://coveralls.io/repos/github/felixrieseberg/electron-wix-msi/badge.svg?branch=master)](https://coveralls.io/github/felixrieseberg/electron-wix-msi?branch=master)
6![TypeScript](https://img.shields.io/badge/typings-included-brightgreen.svg)
7
8## Traditional MSI Installers
9
10Most Electron developers use the official
11[windows-installer](https://github.com/electron/windows-installer) to create
12Windows installers. It does not require Administrator privileges and comes
13bundled with an automatic updater. If your app targets consumers, it will likely
14be the better choice.
15
16However, if you need to create a traditional MSI the way Microsoft intended for
17software to be installed, this module is your friend. It creates a standalone
18MSI that installs your application to `Program Files` or any user-defined
19directory, much like the installers for Office, Node.js, or other popular apps.
20It allows up- and downgrades. For more details, see:
21[Should I use this?](#should-i-use-this)
22
23## Look & Feel
24
25<p align="center"><img src="https://github.com/felixrieseberg/electron-wix-msi/raw/master/.github/installer.gif" alt="Installer GIF"></p>
26
27## Prerequisites
28
29Before using this module, make sure to
30[install the Wix toolkit v3](http://wixtoolset.org/releases/). Only the command
31line tools are required. If you are using AppVeyor or another Windows CI system,
32it is likely already installed.
33
34```
35npm i --save-dev electron-wix-msi
36```
37
38## Usage
39
40Creating an installer is a three-step process:
41
42```js
43import { MSICreator } from 'electron-wix-msi';
44
45// Step 1: Instantiate the MSICreator
46const msiCreator = new MSICreator({
47 appDirectory: '/path/to/built/app',
48 description: 'My amazing Kitten simulator',
49 exe: 'kittens',
50 name: 'Kittens',
51 manufacturer: 'Kitten Technologies',
52 version: '1.1.2',
53 outputDirectory: '/path/to/output/folder'
54});
55
56// Step 2: Create a .wxs template file
57await msiCreator.create();
58
59// Step 3: Compile the template to a .msi file
60await msiCreator.compile();
61```
62
63### Configuration
64
65* `appDirectory` (string) - The source directory for the installer, usually the
66 output of
67 [electron-packager](https://github.com/electron-userland/electron-packager).
68* `outputDirectory` (string) - The output directory. Will contain the finished
69 `msi` as well as the intermediate files .`wxs` and `.wixobj`.
70* `exe` (string) - The name of the exe.
71* `description` (string) - The app's description.
72* `version` (string) - The app's version.
73* `name` (string) - The app's name.
74* `manufacturer` (string) - Name of the manufacturer.
75
76* `appUserModelId` (string, optional) - String to set as `appUserModelId` on the
77 shortcut. If none is passed, it'll be set to `com.squirrel.(Name).(exe)`,
78 which should match the id given to your app by Squirrel.
79* `shortName` (optional, string) - A short name for the app, used wherever
80 spaces and special characters are not allowed. Will use the name if left
81 undefined.
82* `shortcutFolderName` (string, optional) - Name of the shortcut folder in the
83 Windows Start Menu. Will use the manufacturer field if left undefined.
84* `programFilesFolderName` (string, optional) - Name of the folder your app will
85 live in. Will use the app's name if left undefined.
86* `upgradeCode` (string, optional) - A unique UUID used by your app to identify
87 itself. This module will generate one for you, but it is important to reuse it
88 to enable conflict-free upgrades.
89* `language` (number, optional) - The
90 [Microsoft Windows Language Code identifier](https://msdn.microsoft.com/en-us/library/cc233965.aspx)
91 used by the installer. Will use 1033 (English, United-States) if left
92 undefined.
93* `certificateFile` (string, optional) - The path to an Authenticode Code
94 Signing Certificate.
95* `certificatePassword` (string, optional) - The password to decrypt the
96 certificate given in `certificateFile`.
97* `signWithParams` (string, optional) - Paramaters to pass to `signtool.exe`.
98 Overrides `certificateFile` and `certificatePassword`.
99* `ui` (UIOptions, optional) - Enables configuration of the UI. See below for
100 more information.
101
102##### UI Configuration (Optional)
103
104The `ui` property in the options passed to the installer instance allows more
105detailed configuration of the UI. It has the following optional properties:
106
107* `enabled` (boolean, optional) - Whether to show a typical user interface.
108 Defaults to `true`. If set to `false`, Windows will show a minimal "Windows is
109 configuring NAME_OF_APP" interface.
110* `template` (string, optional) - Substitute your own XML that will be inserted
111 into the final `.wxs` file before compiling the installer to customize the UI
112 options.
113* `chooseDirectory` (boolean, optional) - If set to `true`, the end user will be
114 able to choose the installation directory. Set to `false` by default. Without
115 effect if a custom `template` is used.
116* `images` (Optional) - Overwrites default installer images with custom files. I
117 recommend JPG.
118 * `background` - (optional, string) 493 x 312 Background bitmap used on the
119 welcome and completion dialogs. Will be used as `WixUIDialogBmp`.
120 * `banner` - (optional, string) 493 × 58 Top banner used on most dialogs that
121 don't use `background`. Will be used as `WixUIBannerBmp`.
122 * `exclamationIcon` - (optional, string) 32 x 32 Exclamation icon on the
123 `WaitForCostingDlg` dialog. Will be used as `WixUIExclamationIco`.
124 * `infoIcon` - (optional, string) 32 x 32 Information icon on the cancel and
125 error dialogs. Will be used as `WixUIInfoIco`.
126 * `newIcon` - (optional, string) 16 x 16 "New folder" icon for the "browse"
127 dialog. Will be used as `WixUINewIco`.
128 * `upIcon` - (optional, string) 16 x 16 "Up" icon for the "browse" dialog.
129 Will be used as `WixUIUpIco`.
130
131##### Template Configuration (Optional)
132
133This module uses XML bulding blocks to generate the final `.wxs` file. After
134instantiating the class, but before calling `create()`, you can change the
135default XML. The available fields on the class are:
136
137* `componentTemplate` (string) - Used for `<Component>` elements. One per file.
138* `componentRefTemplate` (string) - Used for `<ComponentRef>` elements. Again,
139 one per file.
140* `directoryTemplate` (string) - Used for `<Directory>` elements. This module
141 does not use `<DirectoryRef>` elements.
142* `wixTemplate` (string) - Used as the master template.
143* `uiTemplate` (string) - Used as the master UI template.
144* `backgroundTemplate` (string) - Used as the background template.
145
146## Should I use this?
147
148Let's start with what's bad about this: Electron is based on Chromium, and as
149such, inherintly dependent upon frequent updates. Whenever a new version of
150Electron comes out, you should release a new version of your app. The default
151installer for Windows is based on
152[Squirrel](https://github.com/Squirrel/Squirrel.Windows), which comes with
153support for automatic updates. An app that updates itself is fantastic for most
154consumers. If you are not sure if you need a traditional MSI, chances are that
155you don't.
156
157> "Young man, creating an installer and dying is easy. Updating it and living is
158> harder."
159>
160> -- Windows George Washington, 1776
161
162If you are however developing enterprise software, you might find that IT
163departments don't want automatically updating software. They want controlled
164rollouts and detailed control over the installation. This is true for
165universities, hospitals, the military, and many other organizations that have a
166managed IT infrastructure. Their administrators will expect a "classic"
167installer - the same way they would install Microsoft Office, Node.js,
168Photoshop, or any other software. If you see your app being used in those
169environments, you should push the self-updating package, but have a traditional
170MSI in your pocket. Bear in mind however that you will need to find a way to get
171updates to your users without relying on Electron's auto updater.
172
173## MSI Administration
174The `msi` packages created with this module allow for a wide range of command line parameters. The installer is a "Windows Installer", meaning that the actual installer's logic is part of Windows itself. It supports the following command-line parameters:
175
176#### Install Options
177`</uninstall | /x>` Uninstalls the product
178
179#### Display Options
180- `/quiet` Quiet mode, no user interaction
181- `/passive` Unattended mode - progress bar only
182- `/q[n|b|r|f]` Sets user interface level
183 - n No UI
184 - b Basic UI
185 - r Reduced UI
186 - f Full UI (default)
187`/help` Help information
188
189#### Restart Options
190- `/norestart` Do not restart after the installation is complete
191- `/promptrestart` Prompts the user for restart if necessary
192- `/forcerestart` Always restart the computer after installation
193
194#### Logging Options
195- `/l[i|w|e|a|r|u|c|m|o|p|v|x|+|!|*] <LogFile>`
196 - `i` Status messages
197 - `w` Nonfatal warnings
198 - `e` All error messages
199 - `a` Start up of actions
200 - `r` Action-specific records
201 - `u` User requests
202 - `c` Initial UI parameters
203 - `m` Out-of-memory or fatal exit information
204 - `o` Out-of-disk-space messages
205 - `p` Terminal properties
206 - `v` Verbose output
207 - `x` Extra debugging information
208 - `+` Append to existing log file
209 - `!` Flush each line to the log
210 - `*` Log all information, except for v and x options
211- `/log <LogFile>` Equivalent of /l* <LogFile>
212
213#### Update Options
214- `/update <Update1.msp>[;Update2.msp]` Applies update(s)
215
216#### Repair Options
217- `/f[p|e|c|m|s|o|d|a|u|v]` Repairs a product
218 - `p` only if file is missing
219 - `o` if file is missing or an older version is installed (default)
220 - `e` if file is missing or an equal or older version is installed
221 - `d` if file is missing or a different version is installed
222 - `c` if file is missing or checksum does not match the calculated value
223 - `a` forces all files to be reinstalled
224 - `u` all required user-specific registry entries (default)
225 - `m` all required computer-specific registry entries (default)
226 - `s` all existing shortcuts (default)
227 - `v` runs from source and recaches local package
228
229## License
230
231MIT, please see LICENSE.md for details.