I wrote an article a month or two ago called Creating a Windows Distribution of an Electron App using Squirrel. In it I manually gathered the pieces I needed to create the package to be distributed and hack the executable's resources by hand. This was cumbersome and I recently learned there is a pretty cool project called electron-packager that will do a lot of this for you. I took it for a spin tonight.

Get Electron-Packager

With the beauty of most things that are Node, electron-packager is available via npm. Here is the command to get it:

npm i electron-packager -g

Of course, this can also be saved to the development work space if needed.

Use Electron-Packager

In Creating a Windows Distribution of an Electron App using Squirrel I have you create a 'Staging' to load everything into. Without worrying about resources hacking or copying and pasting here is the command I would to have electron-packager do the heavy lifting:

electron-packager <dir> <app_name> --platform=win32 --arch=all --version=<electron_version> --icon=<path_to_icon> --out=Staging --version-string.CompanyName=<my_company_name>--version-string.ProductName=<my_product_name> --version-string.ProductVersion=<product_version>

Here is a bit of a break down:

  • <dir> replace this with the path to your app folder.
  • <app_name> this is the name of your app.
  • --platform=win32 you can build for all platforms, but I only run Windows at the moment so that is all I built for. This is required.
  • --arch=all you can choose to build for 32 bit or 64 bit or both. I just went with all.
  • --version=<electron_version> replace with the version of Electron you want to use.
  • --icon=<path_to_icon> provide the path to the .ico file you want to use, placed in the .exe's resources.
  • --out=Staging where you want the output to go, i chose staging.
  • --version-string.CompanyName=<my_company_name> puts your company name in the Version Info resources of the executable.
  • --version-string.ProductName=<my_product_name> puts the name of the product into the Version Info resources of the executable.
  • --version-string.ProductVersion=<product_version> puts your product version in the Version Info resources of the executable.

When you are done running the command folders of form -- are created. If you are creating a package for Squirrel.Windows you'll want to make sure you update the .nuspec file to point to the new directories created by electron-packager.

Sorry I did not go in-depth on this. The documentation for electron-packager is pretty self-explanatory. Check out the full documentation for electron-packager here: https://github.com/maxogden/electron-packager