为应用程序制作桌面安装程序?

我已经使用了一段时间的电子,并build立了几个应用程序,但还没有计算出如何去创build一个桌面图标和Windows安装程序(在电子主页上,它具体说,使Windows安装程序“变得容易”。 )

我将如何去做这样一个安装程序的Windows,以及已经自动安装桌面图标(。桌面的GNOME,Windows的快捷方式),为一个典型的电子设置的应用程序?

我知道这可能看起来像一个愚蠢的问题,但我不明白不那么具体的指示(例如http://electron.atom.io/docs/v0.34.0/tutorial/application-distribution/类似的帮助,但也是模糊。)

我之前做过一些研究,发现创buildWindows安装程序并不容易。

  1. 使用grunt-electron-installer创buildWindows安装程序。 请注意,它只会在安装时显示gif。 没有交互式对话框。 它使用Squirrel.Windows 。

  2. 使用Update.exe --createShortcut=<comma separated locations> <your exe>来创build快捷方式。 可用位置包括DesktopStartMenuStartupAppRoot

    Update.exe将在安装时与您的应用一起发货。 我发现这篇文章非常有帮助。 总之,你需要这样的东西:

     var app = require('app'); var path = require('path'); var cp = require('child_process'); var handleSquirrelEvent = function() { if (process.platform != 'win32') { return false; } function executeSquirrelCommand(args, done) { var updateDotExe = path.resolve(path.dirname(process.execPath), '..', 'update.exe'); var child = cp.spawn(updateDotExe, args, { detached: true }); child.on('close', function(code) { done(); }); }; function install(done) { var target = path.basename(process.execPath); executeSquirrelCommand(["--createShortcut", target], done); }; function uninstall(done) { var target = path.basename(process.execPath); executeSquirrelCommand(["--removeShortcut", target], done); }; var squirrelEvent = process.argv[1]; switch (squirrelEvent) { case '--squirrel-install': install(app.quit); return true; case '--squirrel-updated': install(app.quit); return true; case '--squirrel-obsolete': app.quit(); return true; case '--squirrel-uninstall': uninstall(app.quit); return true; } return false; }; if (handleSquirrelEvent()) { return; } 

请注意,在较新版本的Electron中,您可以使用auto-updater来处理Squirrel.Windows事件,但API有点不同,所以我不确定如何使用auto-updater正确执行。