It’s not just enough to create applications, we have to publish them on stores or websites for our real users to start using them. Also, as per current needs, applications should support all major OS like Windows, macOS, and Linux.
Today, we will learn how to generate a build of electron app for windows OS.
We will build the app using electron-builder and vue-cli-plugin-electron-builder and will package it with electron-windows-store.
Interested in MacOS desktop build? check out our following article,
We are what we repeatedly do. Excellence, then, is not an act, but a habit. Try out Justly and start building your habits today!
Some days ago, we got a requirement to generate windows build of an electron desktop app.
We went through a few references but didn’t find enough guides. After spending much more time we finally got it done with fewer but simple steps.
I strongly feel that the efforts I have put in can be worthy for others as well. So, today I’m sharing the steps with which you can build your desktop app without wasting your time.
I have used Vue.js
inside the electron.js
app for creating an app. You can do the same config with whichever framework you have used.
Note: I’m assuming you have created a Microsoft store account and a product app on Microsoft store. Also, you already have
Publisher dentity (CN=developmentca)
. If not yet, you can start from here.
As vue-cli-plugin-electron-builder built on top of the electron-builder, it will be installed when we install vue-cli-plugin-electron-builder
.
Install using npm,
npm i vue-cli-plugin-electron-builder --save-dev
Images are a visual representation of our app. For windows os, we will need icons and logos of different sizes to build the app.
Here is a list of images required for the windows app.
Microsoft store
.start menu
of windows and on Microsoft store listing apps
.Start menu app list
and task bar
.Start menu
on windows.Prepare all images as per the given name and sizes, and place them in resources/appx
of the root directory.
AppX config should be like the below,
module.exports = {
pluginOptions: {
electronBuilder: {
builderOptions: {
productName: "Your product name",
directories: {
buildResources: "resources",
},
win: {
icon: "resources/appx/storeLogo.png",
target: ["nsis", "appx"],
},
appx: {
identityName: "Your app identity name",
publisher: "Your app publisher identity",
publisherDisplayName: "Your app publisher name",
},
},
},
},
};
You can add more properties as per the requirements given on the electron-builder docs.
Till now, we are done with all configurations.
Now let’s jump to the app building.
Add the following command inside the scripts
block of the package.json
file.
"build:win": "vue-cli-service electron:build --windows"
Now, you can build an app with the following command.
npm run build:win
You will find .appx and .exe apps in dist_electron
directory.
we will use electron-windows-store for packaging windows appX. Install it using the given command on windows os.
npm i -g electron-windows-store
Follow the below steps to create an AppX bundle, which we will publish on the Microsoft store.
windows os
version from the link, install it, and get the installed SDK path. In my case, it is at C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.1\x86
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
3. Now, run the below command. This will open the CLI windows-store.
electron-windows-store
4. It will ask some questions like creating certificates
and to add publisher identity
and SDK path
. Answer them accordingly.
5. Stop the process by ctrl+c
.
electron-windows-store settings saved atC:\Users\${username}\.electron-windows-store
and certificates saved at C:\Users\${username}\AppData\Roaming\electron-windows-store
.
If you feel anything wrong with it, just delete them and follow from 3rd step again.
Now, it’s time to build a production-ready build for publishing on the Microsoft store.
To create the AppX build, run the below command,
electron-windows-store --input-directory "Your dist_electron path" --output-directory "Your output path" --package-version 1.0.0.0 --package-name "Your .exe name" --package-display-name "Your app display name" --publisher-display-name "App's publisher identity name" --identity-name "App's product identity name" -a "Resources path"
This command will use the electron-windows-store configuration which we have created from the above steps and generate the AppX build.
Let’s understand all options…
dist_electron
in our case. Make sure it should have .exe
.appx
files only.1.0.2
, then it should be 1.0.2.0
.Now, you have the final production-ready build to upload to the Microsoft store.
Upload appx
package on the windows partner dashboard
and submit it to the store.
The certification process by Microsoft Store will take some days. If everything goes fine, you should have your windows app published on the Microsoftstore🎉.
Building a Windows app using an electron-builder is easy, except for the packaging and code signing process by the windows store.
You can also configure the build on CI/CD to automate the building process. That way, whenever you perform any changes in your existing code, the build will be generated automatically and will also be uploaded to the store.
We’re Grateful to have you with us on this journey!
Suggestions and feedback are more than welcome!
Please reach us at Canopas Twitter handle @canopas_eng with your content or feedback. Your input enriches our content and fuels our motivation to create more valuable and informative articles for you.
Get started today
Let's build the next
big thing!
Let's improve your business's digital strategy and implement robust mobile apps to achieve your business objectives. Schedule Your Free Consultation Now.
Get Free ConsultationGet started today
Let's build the next big thing!
Let's improve your business's digital strategy and implement robust mobile apps to achieve your business objectives. Schedule Your Free Consultation Now.
Get Free Consultation