簡體   English   中英

使用 electron-builder 從 electron 應用程序構建standalone.exe

[英]Build standalone .exe from electron app using electron-builder

我正在使用 electron v6.0.9 和電子生成器 v21.2.0。 這是我的package.json用於生產構建的包裝配置。

"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
    }
  },

我在script中將構建腳本配置為"pack": "electron-builder --dir -mwl", 問題是,當我運行命令npm run pack時,它會為所有平台打包應用程序,但對於 windows,沒有單個安裝程序文件.exe或“.msi”。 electron-builder為 windows 構建一堆文件。

我在 macOS High Sierra v10.13.6 (17G8030) 上運行。 我也嘗試在 windows 10 系統上構建,但結果是一樣的。 這里是否有任何錯誤配置,或者需要更多步驟來為 windows 生成單個安裝程序文件?

我想出了如何從 electron 源代碼而不是一堆文件構建獨立安裝程序。 實際上,我們必須將electron-builder-p一起使用。 這是我的package.json文件中的構建配置。

"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"
      }
    ]
  }

directory.然后我只使用了electron-builder -p never --win並將.exe文件打包在目錄中。 如果您使用來自electron-builderauto-updator器並希望在 github 存儲庫中發布發布草案,則可以-p always

如果您想覆蓋默認安裝位置並讓用戶選擇它,請確保您已按如下方式配置nsis構建,

"nsis": {
      "oneClick": false,
      "perMachine": false,
      "allowToChangeInstallationDirectory": true
},

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM