7

I'm using electron v6.0.9 with electron-builder v21.2.0. Here is the packaging configuration from my package.json for a production build.

"build": {
    "appId": "com.app.prototype",
    "productName": "Pluto",
    "copyright": "Copyright © 2018 Simon Inc.",
    "mac": {
      "target": [
        "zip"
      ]
    },
    "win": {
      "publisherName": "Simon Inc.",
      "target": [
        "nsis",
        "zip"
      ]
    },
    "linux": {
      "target": [
        "AppImage",
        "tar.gz"
      ]
    },
    "dmg": {
      "icon": "build/icon.icns"
    },
    "publish": {
      "provider": "generic",
      "url": "THE_RELEASE_URL_HERE",
      "channel": "latest",
      "publishAutoUpdate": true
    }
  },

I configured the build script as "pack": "electron-builder --dir -mwl", in script. The issue is, when i run the command npm run pack, it packages the application for all the platform, but for windows there is no single installer file either .exe or '.msi'. electron-builder builds bunch of files for windows.

I'm running on macOS High Sierra v10.13.6 (17G8030). I also tried building on windows 10 system but outcome is the same. is anything misconfigured here or there some more steps required to generate single installer file for windows?

Kiran Maniya
  • 8,453
  • 9
  • 58
  • 81
  • Where you have define that with method you are using for window ? means its `nsis`,`appX` or `squirrel.windows` – Mayank Vadiya Oct 03 '19 at 05:34
  • look at my `package.json` above. I'm targetting nsis and zip – Kiran Maniya Oct 03 '19 at 06:10
  • you figure this out? i tried using `electron-packager`, and it simply creates a folder with a bunch of files including the `exe`. is there any way to package the electron application like a normal program, whereby you run the `exe` to install the application in the system etc? – oldboy Oct 19 '19 at 12:14
  • @BugWhisperer Yes, using `electron-builder` and target for `nsis`. Run `electron-builder -p never --win` to build the installer. check the answer for details – Kiran Maniya Oct 19 '19 at 19:08
  • sweet thanks BUT you forgot to link to the answer?? – oldboy Oct 19 '19 at 19:52
  • also, is it possible to create desktop shortcuts etc? – oldboy Oct 19 '19 at 20:05
  • @BugWhisperer After install the .exe generated, it will create a desktop shortcut also. – Kiran Maniya Oct 20 '19 at 05:58
  • i could only get `electron-packager` working. i had troubles trying to use `electron-builder`, so i have one last question: when using `electron-builder` to create the `.exe` executable, if the user clicks the `.exe`, does it prompt the user to choose which folder to install it to? – oldboy Oct 20 '19 at 07:57
  • Yes, You can configure the electron-builder to do so. – Kiran Maniya Oct 20 '19 at 09:24
  • How do you set it up so that **the user can choose which folder** to unpack the `exe` upon installation? – oldboy Oct 20 '19 at 23:08
  • can you provide me with a link to some info regarding that? – oldboy Oct 21 '19 at 06:01
  • @BugWhisperer everything is here https://www.electron.build/ if you still can't find anything. comment here i'll try to post minimal example here – Kiran Maniya Oct 21 '19 at 06:33
  • 1
    i found it `"nsis": { "oneClick": false }`, but, although this creates the install popup window, it doesnt let the user choose which window? -- NEVERMIND, its right underneath :D sorry for spam of msgs – oldboy Oct 21 '19 at 06:37
  • nevermind my friend, it was right underneath. (sorry for spam of msgs) – oldboy Oct 21 '19 at 06:39
  • If it doesn't late the user select the install location, it's definitely installed it on app data. I checked in electron-based app (VSCode), It also gets installed in AppData – Kiran Maniya Oct 21 '19 at 06:39
  • 1
    try adding `"allowToChangeInstallationDirectory": true` in `nsis` build config – Kiran Maniya Oct 21 '19 at 06:41
  • 1
    its because `"allowToChangeInstallationDirectory"` defaults to `false`. i have to make that true i think – oldboy Oct 21 '19 at 06:41

1 Answers1

6

I figured it out about how to build a standalone installer from electron source rather than having a bunch of files. Actually we have to use electron-builder with -p. Here is the build configuration in my package.json file.

"build": {
    "appId": "com.trinityinfosystem.accurate",
    "productName": "Accurate",
    "copyright": "Copyright © 2018 Trinity InfoSystem",
    "mac": {
      "target": [
        "zip"
      ],
      "publish": [
        "github"
      ]
    },
    "win": {
      "publisherName": "Trinity InfoSystem",
      "publish": [
        "github"
      ],
      "target": [
        "nsis"
      ]
    },
    "linux": {
      "target": [
        "AppImage",
        "tar.gz"
      ]
    },
    "dmg": {
      "icon": "build/icon.icns"
    },
    "publish": [
      {
        "provider": "github",
        "owner": "vkiranmaniya",
        "repo": "accurate",
        "vPrefixedTagName": true,
        "private": true,
        "releaseType": "draft"
      }
    ]
  }

then i just used electron-builder -p never --win and it packed up the .exe file in project_root/dist directory. You can use -p always if you are using auto-updator from electron-builder and want to publish a release draft in github repository.

If you want to override default install location and let the user choose it, make sure you have configured the nsis build as follow,

"nsis": {
      "oneClick": false,
      "perMachine": false,
      "allowToChangeInstallationDirectory": true
},
Kiran Maniya
  • 8,453
  • 9
  • 58
  • 81