【问题标题】:electron updater notify for new release but do not update or download new release in windows电子更新程序通知新版本,但不在 Windows 中更新或下载新版本
【发布时间】:2020-05-07 07:06:29
【问题描述】:

electron updater 4.2.0 包不下载新版本但可以检测到

这是github上的私有仓库

新版本成功发送到github

package.json 中:

"build": {
"appId": "com.myApp.ID",
"npmRebuild": false,
"win": {
  "icon": "./resources/electron/icons/256x256.png",
  "publish": [
    {
      "provider": "github",
      "owner": "me",
      "repo": "POS",
      "private": true,
      "releaseType": "release",
      "token": "<private token>"
    }
  ],
  "target": [
    {
      "target": "nsis",
      "arch": [
        "x64"
      ]
    }
  ]
}
},

我的 electron.js 文件或 main.js 我有:

  win.webContents.on('did-finish-load', () => {
    if(!serve) {
      appUpdater(win);
    }
  });

appUpdater 功能是:

function appUpdater(win) {
  autoUpdater.autoInstallOnAppQuit = true;
  autoUpdater.autoDownload = true;
  autoUpdater.logger = logger;
  /* Log whats happening
  TODO send autoUpdater events to renderer so that we could console log it in developer tools
  You could alsoe use nslog or other logging to see what's happening */
  let foundUpdate = false;
  autoUpdater.on('checking-for-update', () => {
    dialog.showMessageBox(win, {
      message: 'CHECKING FOR UPDATES !!'
    });
  });
  autoUpdater.on('update-available', () => {
    foundUpdate = true;
    dialog.showMessageBox(win, {
      message: ' update-available !!'
    });
  });
  autoUpdater.on('error', error => {
    autoUpdater.logger.debug(error);
  });
  // Ask the user if update is available
  autoUpdater.on('update-downloaded', (_event, releaseNotes, _releaseName) => {
    let message = 'A new version is now available. It will be installed the next time you restart the application.';
    dialog.showMessageBox(win, {
      type: 'question',
      buttons: ['Install', 'Later'],
      defaultId: 0,
      message: 'A new version has been downloaded',
      detail: message
    }, response => {
      if(response === 0) {
        setTimeout(() => autoUpdater.quitAndInstall(), 1);
      }
    });
  });
  // init for updates
  setInterval(() => {
    if(!foundUpdate) {
      autoUpdater.checkForUpdates();
    }
  }, 60000);
}
exports.appUpdater = appUpdater;

我从auto updater得到记录

自动更新目标是 windows nsis

checking-for-update 和 update-available 事件正确触发,但 update-downloaded or error 根本不触发

如果您已经有这方面的经验,请告诉我

注意:我也在用户机器中设置了环境变量 GH_TOKEN

【问题讨论】:

  • 这似乎是一个错误,我可以在这里看到修复:github.com/electron-userland/electron-builder/releases update electron-builder to latest,但实际上它仍然对我不起作用
  • NSIS 标签真的相关吗?
  • @Anders 你是什么意思?我想我的问题来自here 它说:注意在 package.json 这部分: "win": { "certificateFile": "./certs/my_signing_key.pfx", "certificatePassword": "" } 我生成了虚拟证书来签署这个应用程序, 如果您不提供这些文件,自动更新将不起作用! 将这些行替换为您自己的证书信息
  • 我的意思是,您可能正在生成 NSIS 安装程序,但您的问题似乎与 NSIS 无关。
  • 好的 @Anders 我只是提供一些有关该项目的更多信息,以便了解出了什么问题,因此,如果您有任何意见要在我的代码中使其正常工作,欢迎!

标签: electron nsis electron-updater


【解决方案1】:

electron-builder 和 electron-updater 的某些特定版本也存在同样的问题。对我来说,它完全适用于:

"electron-builder": "22.11.7"
"electron-updater": "4.3.8"

但例如,它不再适用于 electron-updater 4.3.9 ...

【讨论】:

    【解决方案2】:

    现在总比以前好 我正在为 mac bigSur 的新更新而苦苦挣扎,因为 electron-builder@^20.38.0 给了我非常糟糕的错误!!! 所以我决定更新到最新版本

    electron: ^12.0.2
    electron-builder: ^22.10.5
    electron-updater: ^4.3.8
    

    起初它没有工作给我这样的错误: 无法差异下载,回退到完整下载:错误:最大允许大小为 50 MB

    最后我本地的node版本是v10.15.1 我更新到 v14.16.0 现在可以使用了!

    使用其他版本更新和降级的另一个问题 正在下载,但安装失败。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多