【发布时间】: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