Releasing Electron applications on Windows can be a tricky issue. Especially if you mainly use a Mac (like me). And you have to think about that pesky code signing thing you have to do to avoid the annoying ‘SmartScreen’ filter users may get.
Thankfully, there’s a great tool called Squirrel made by Paul Betts that does a ton of the heavy lifting for you. Codesigning and all.
I really got a ton of knowledge from the blog post, Creating a Windows Distribution of an Electron App using Squirrel and Using Electron Packager to Package an Electron App.
I wanted to curate a ton of knowledge in one place, so here we go.
I use a few tools to get this done on my Mac:
First, let’s look at the project layout:
Project Layout
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
Process
First we’ll need to make the exe and associated files to a dist
folder. From there, we take the win dist
files and pack them into the Setup.exe
file, where Squirrel will do the heavy lifting to pack all this into a one step process.
npm Scripts
We’ll use the npm script pack:win
task to put all our www
files into a nice package (resources, exe, etc) and output to the dist
folder.
pack:win
step will just execute electron-packager
with some relevant information. Please note the asar=true
, this is recommended because sometimes node_modules
can get nested a few times and the file paths will be too long for certain Windows platforms.
Script:
1 2 3 4 |
|
Electron Build script
I used a simple build script in node to assist in some of the heavy lifting. I recommend getting an Extended Validation certificate from this blog post.
This will take the windows package in dist/win
and create dist/win/Setup.exe
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
Hope this helps!