私はElectronアプリを持っており、Windowsインストーラを作るためにMacで作業しています。Electronを使ってSquirrelイベントでデスクトップショートカットを作成する
今、私は/installersディレクトリと、すべてのSquirrelイベントを処理するsetupEvents.jsファイルを持っています。そのほとんどがWindows installer documentationからです:
import { app } from 'electron';
module.exports = {
handleSquirrelEvent: function() {
if (process.argv.length === 1) {
return false;
}
const ChildProcess = require('child_process');
const path = require('path');
const appFolder = path.resolve(process.execPath, '..');
const rootAtomFolder = path.resolve(appFolder, '..');
const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'));
const exeName = path.basename(process.execPath);
const spawn = function(command, args) {
let spawnedProcess, error;
try {
spawnedProcess = ChildProcess.spawn(command, args, {detached: true});
} catch (error) {}
return spawnedProcess;
};
const spawnUpdate = function(args) {
return spawn(updateDotExe, args);
};
const squirrelEvent = process.argv[1];
switch (squirrelEvent) {
case '--squirrel-install':
case '--squirrel-updated':
// Optionally do things such as:
// - Add your .exe to the PATH
// - Write to the registry for things like file associations and
// explorer context menus
// Install desktop and start menu shortcuts
spawnUpdate(['--createShortcut', exeName]);
setTimeout(app.quit, 1000);
return true;
case '--squirrel-uninstall':
// Undo anything you did in the --squirrel-install and
// --squirrel-updated handlers
// Remove desktop and start menu shortcuts
spawnUpdate(['--removeShortcut', exeName]);
setTimeout(app.quit, 1000);
return true;
case '--squirrel-obsolete':
// This is called on the outgoing version of your app before
// we update to the new version - it's the opposite of
// --squirrel-updated
app.quit();
return true;
}
}
}
これまでのところ、期待通りにデスクトップに追加されたショートカットアイコンがタイトル「エレクトロン」を持っている以外、これは、動作し、私はそれを変更するかどうかはわかりません。私のpackage.jsonはそれに名前や商品名を持っています
{
"name": "my app",
"description": "my app description",
"productName": "my app",
"appCopyright": "me",
"appCategoryType": "Productivity",
...
そして、私のインストーラの設定は次のようになります。
{
appDirectory: path.join(outPath, 'myapp-win32-ia32/'),
authors: 'me',
noMsi: true,
outputDirectory: path.join(outPath, 'windows-installer'),
exe: 'myapp.exe',
setupExe: 'myappInstaller.exe',
setupIcon: path.join(rootPath, 'assets', 'win', 'icon.ico'),
skipUpdateIcon: true
}
私は、ショートカットアイコンが持つべきインストーラに指示する場所がわからないんだけど私のアプリの名前だけではなく、 "電子"。
ありがとうございます!
これは働いていました!ありがとうございました!! –
これは 'win32metadata'になりました –