使用电子生成器从电子应用程序构建独立的.exe

问题描述 投票:0回答:1

我正在使用电子版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
    }
  },

我在"pack": "electron-builder --dir -mwl",中将构建脚本配置为script。问题是,当我运行命令npm run pack时,它将为所有平台打包应用程序,但对于Windows,没有单个安装程序文件.exe或'.msi'。 electron-builder为Windows构建一堆文件。

我正在macOS High Sierra v10.13.6(17G8030)上运行。我也尝试在Windows 10系统上构建,但结果是相同的。这里是否配置错误,还是需要为Windows生成单个安装程序文件而执行一些其他步骤?

windows macos electron installer electron-builder
1个回答
0
投票

我想出了如何从电子源构建一个独立的安装程序,而不是拥有大量文件的方法。实际上,我们必须将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"
      }
    ]
  }

然后我只用了electron-builder -p never --win,它把。exe文件打包在project_root / dist目录中。如果您要使用-p always中的auto-updator,并且想在github仓库中发布发布草案,则可以使用electron-builder

© www.soinside.com 2019 - 2024. All rights reserved.