Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Windows Store Guide


May 25, 2021 Electron


Table of contents


In Windows 8, some nice old win32 programs have a new friend: Universal Windows Platform (UWP). The .appx not only enables many new and powerful APIs, such as Cortana or push notifications, but also simplifies installation and updates through the Windows Store.

Microsoft has developed a tool to compile the Electron application .appx package that enables developers to use some of the good things in the new application model. This guide explains how to use it - and the features and limitations of the Electron AppX package.

Background and requirements

Windows 10's "Anniversary Update" runs win32 .exe and their virtualized file systems and registries start with them. B oth were created by running applications in Windows containers and compiling installers, allowing Windows to correctly identify which modifications were made to the operating system during installation. Pair executables and virtual file systems with the virtual registry, allowing Windows to enable one-click installation and uninstall.

In addition, exe starts within the appx model - which means it can use many of the APIs available on the Universal Windows platform. For more functionality, the Electron application can be used with an invisible UWP background task, exe receiver for a background running task, receives push notifications, or communicates with other UWP applications.

To compile any existing Electron application, make sure that the following requirements are met:

  • Windows 10 and Anniversary Update (released August 2, 2016)
  • Windows 10 SDK, download here
  • Latest Node 4 node -v to confirm)

Then, install electron-windows-store CLI:

npm install -g electron-windows-store

Step 1: Package your Electron application

Packaged applications use electron-packager (or similar tools). Make sure to remove unwanted node_modules as these you do not need modules will only increase the size of your application.

The structure output should look something like this:

├── Ghost.exe
├── LICENSE
├── content_resources_200_percent.pak
├── content_shell.pak
├── d3dcompiler_47.dll
├── ffmpeg.dll
├── icudtl.dat
├── libEGL.dll
├── libGLESv2.dll
├── locales
│   ├── am.pak
│   ├── ar.pak
│   ├── [...]
├── natives_blob.bin
├── node.dll
├── resources
│   ├── app
│   └── atom.asar
├── snapshot_blob.bin
├── squirrel.exe
├── ui_resources_200_percent.pak
└── xinput1_3.dll

Step 2: Run electron-windows-store

From the weighted PowerShell (run it as an administrator), run electron-windows-store pass the input and output directories, the name and version of the node_modules and confirm that the node_modules should be flat.

electron-windows-store `
    --input-directory C:\myelectronapp `
    --output-directory C:\output\myelectronapp `
    --flatten true `
    --package-version 1.0.0.0 `
    --package-name myelectronapp

Once executed, the tool starts working: it accepts your Electron application as input, node_modules I t then archives the application as app.zip Using the installer and Windows container, the tool creates an "extended" AppX package - including the Windows Application Inventory AppXManifest.xml and the virtual registry in the virtual file system and output folders.

When you create extended AppX files, the tool uses Windows App Packager MakeAppx.exe to create these files on disk as single-file AppX packages. F inally, the tool can be used to create a trusted certificate on your computer to sign a new AppX package. With a signed AppX package, the CLI can also automatically install the package on your computer.

Step 3: Use the AppX package

In order to run your package, your users will need to install Windows 10 with Anniversary Update - more information about how to update Windows can be found here

Unlike traditional UWP applications, packaged applications currently require a manual verification process, which you can apply for here. In the meantime, all users will be able to install your program by double-clicking on the installation package, so if you're just looking for an easier installation method, you probably won't need to submit it to the store.

In a managed environment, typically an enterprise, Add-AppxPackage PowerShell Cmdlet can be used to install it automatically.

Another important limitation is that the compiled AppX package still contains a win32 executable and therefore does not run in Xbox, HoloLens, or Phones.

Optional: Add the UWP feature with BackgroundTask

You can pair your Electron application with invisible UWP background tasks to take advantage of Windows 10 features such as push notifications, Cortana integration, or active tiles.

Using the Electron app to send toast notifications and active tiles through background tasks, check out the microsoft-provided case .

Optional: Transform using container virtualization

To build an AppX package, electron-windows-store CLI should be appropriate for most Electron applications. However, if you use a custom installer, or if you experience any problems with the generated package, you can try using Windows Container Compilation to create the package - in which mode the CLI installs and runs the application in an empty Windows container to determine what modifications the application is making to the operating system.

Before you can run the CLI, you must set up Windows Desktop App Converter. I t will take a few minutes, but don't worry - you just need to do it once. Download Desktop App Converter from here

You'll get two files: DesktopAppConverter.zip BaseImage-14316.wim .

  1. DesktopAppConverter.zip . Turn on the powerShell (open with "Run with administrator privileges", make sure that your system execution policy allows us to run everything we want to run by calling Set-ExecutionPolicy bypass
  2. Then, by calling .\DesktopAppConverter.ps1 -Setup -BaseImage .\BaseImage-14316.wim run the Desktop App Converter installation, and pass the location of the Windows base image BaseImage-14316.wim ).
  3. If running the above command prompts you to restart, restart your computer and run the command again after a successful restart.

When the installation is successful, you can continue to compile your Electron application.