Electron 使用 electron-builder 创建 MSI 安装程序 [英] Electron create MSI installer using electron-builder

查看:73
本文介绍了Electron 使用 electron-builder 创建 MSI 安装程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法使用电子生成器为 Windows 创建了一个 .exe 安装程序,我创建了 2 个 package.json,正如文档中指出的那样:

"dist:win64": "./node_modules/.bin/build --platform win32 --arch x64"

我的主要 package.json 的构建部分是

构建":{"app-bundle-id": "org.test.mytest","app-category-type": "public.app-category.graphics-design",osx":{内容": [{x":410,y":150,类型":链接",路径":/应用程序"},{x":130,y":150,类型":文件"}]},赢": {"title": "我很棒的应用",版本":2.28.999.1",noMsi":错误,作者":作者"}}

一切正常,我有 .exe 安装程序,但无法使用 .msi 安装程序将内容放入程序文件目录.

相反,我最终在 C:UsersUserHomeAppDataLocalelectron 文件夹中安装了一个安装程序,如下所示.

有没有办法让一个真正的.msi 安装程序使用电子生成器将内容放在程序文件夹中.唯一一个有效的项目是这个 https://github.com/theodo/electron-boilerplate 但它使用的是以前版本的电子生成器.

在电子文档中将 noMsi 设置为 false,应该可以解决问题...

Squirrel.Windows 是否应该创建一个 MSI 安装程序?

解决方案

您实际上不需要安装 MSI 即可将您的应用安装到 Program Files.

如果您在 nsis 配置 (oneClick) 中禁用一键单击,则会提示用户是执行单用户安装(在 AppData 中)还是每台机器(在程序文件).

如果您不想让他们选择,您可以将 perMachine 设置为 false,这将只允许安装到 Program Files:

"nsis": {单次点击":假,每台机器":假},

我个人会让他们选择,因为他们仍然可以在没有管理员权限的情况下安装!

在最新版本的 electron-builder 中还有一个 allowToChangeInstallationDirectory 选项,允许用户选择任何安装位置.

I managed to create an .exe installer for windows using electron builder, I create 2 package.json as pointed out in the docs :

https://github.com/electron-userland/electron-builder.

I ended up having a folder with a working .exe

"dist:win64": "./node_modules/.bin/build --platform win32 --arch x64"

The build section of my main package.json is

"build": {
    "app-bundle-id": "org.test.mytest",
    "app-category-type": "public.app-category.graphics-design",
    "osx": {
      "contents": [
        {
          "x": 410,
          "y": 150,
          "type": "link",
          "path": "/Applications"
        },
        {
          "x": 130,
          "y": 150,
          "type": "file"
        }
      ]
    },
    "win": {
      "title": "My awesome app",
      "version": "2.28.999.1",
      "noMsi": false,
      "authors": "Author"
    }
  }

Everything works fine, I have and .exe installer but no way to have an .msi installer that put the content in program files directory.

Instead I ended up with an installation in the C:UsersUserHomeAppDataLocalelectron folder with and installer like below.

Is there a way to have a real .msi installer using electron builder that put the content in the Program file folder. The only one project that worked is this one https://github.com/theodo/electron-boilerplate but it uses a former version of electron-builder.

In the electron doc setting the noMsi to false, should do the trick ...

Should Squirrel.Windows create an MSI installer?

解决方案

You don't actually need an MSI installed to get your app installed into Program Files.

If you disable one click in the nsis config (oneClick), the user is prompted whether to do the single user install (in AppData) or per machine (in Program Files).

If you don't want to give them the choice, you can set perMachine to false which will only allow install into Program Files:

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

I would personally leave them the option as they can still install without admin rights!

In the latest version of electron-builder there is also a allowToChangeInstallationDirectory option which allows the user to choose any install location.

这篇关于Electron 使用 electron-builder 创建 MSI 安装程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆