ゴール
参考
- GitHub - electron-userland/electron-packager: Customize and package your Electron app with OS-specific bundles (.app, .exe, etc.) via JS or CLI
- No dice: ENOENT: no such file or directory, open 'resources/app/package.json' · Issue #96 · electron/windows-installer · GitHub
手順
Windows用のビルドディレクトリをつくる
Building Windows apps from non-Windows platforms に従って、
% electron-packager . MyApp \ --platform=win64 \ --arch=x64 \ --version=0.0.1 \ --out=builds/windows \ --icon=assets/myapp.icns --overwrite
↓
エラー: Unsupported platform=win64 (string); must be a string matching: darwin, linux, mas, win32
Windows (also known as win32, for both 32/64 bit)
とある。ので、
% electron-packager . MyApp \ - --platform=win64 \ + --platform=win32 \ --arch=x64 \ --version=0.0.1 \ --out=builds/windows \ --icon=assets/myapp.icns --overwrite
エラー: Could not find "wine" on your system.
Packaging app for platform win32 x64 using electron v1.7.5 Could not find "wine" on your system. Wine is required to use the appCopyright, appVersion, buildVersion, icon, and win32metadata parameters for Windows targets. Make sure that the "wine" executable is in your PATH.
Building Windows apps from non-Windows platforms をよく読むと、
so on non-Windows host platforms, Wine 1.6 or later needs to be installed. On OS X, it is installable via Homebrew.
とあるので、
% brew search wine % brew install wine wine: XQuartz is required to install this formula.X11Requirement unsatisfied! You can install with Homebrew-Cask: brew cask install xquartz You can download from: https://xquartz.macosforge.org Error: An unsatisfied requirement failed this build. # ほう? % brew cask install xquartz % brew install wine ==> Summary 🍺 /usr/local/Cellar/wine/2.0.3: 8,252 files, 591.9MB # 入った % which wine /usr/local/bin/wine # PATHも通ってる
electron-packagerによるビルドの成功
% electron-packager . MyApp \ --platform=win64 \ --arch=x64 \ --version=0.0.1 \ --out=builds/windows \ --icon=assets/myapp.icns --overwrite Packaging app for platform win32 x64 using electron v1.7.5 Wrote new app to builds/windows/MyApp-win32-x64
いい感じ。
インストーラの作成
% mkdir scripts % vi scripts/windows-build-installer.js
/* eslint no-console:0 */ var winstaller = require('electron-winstaller'); winstaller.createWindowsInstaller({ appDirectory: './builds/windows/MyApp-win32-x64/', outputDirectory: '/tmp/build/installer64', authors: 'My App Inc.', exe: 'myapp.exe' }) .then(() => console.log('It worked!')) .catch(e => console.log(`No dice: ${e.message}`));
エラー: No dice: spawn mono ENOENT
% node ./scripts/windows-build-installer.js No dice: spawn mono ENOENT
ふむ。
ほう?
% brew search mono
% brew info mono
% brew install mono
% wich mono
/usr/local/bin/mono
インストーラ作成成功
ふたたび
% node ./scripts/windows-build-installer.js It worked! % ls -la /tmp/build/installer64 RELEASES MyApp-0.0.1-full.nupkg Setup.exe
いけてるっぽいぞ。
この.exe
をWindowsで実行したら、無事デスクトップアプリがWindowsで起動した!
Electronではじめるアプリ開発 ~JavaScript/HTML/CSSでデスクトップアプリを作ろう
- 作者: 野口将人,倉見洋輔
- 出版社/メーカー: 技術評論社
- 発売日: 2017/03/28
- メディア: 大型本
- この商品を含むブログ (1件) を見る
DRYな備忘録として