Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for building a single executable for Windows #78

Merged
merged 3 commits into from
Nov 18, 2017

Conversation

Lazza
Copy link
Contributor

@Lazza Lazza commented Nov 13, 2017

When building for Windows, sometimes it is desirable to include everything in a single .exe file rather than having a directory full of files. This PR leverages electron-builder to provide this option.

The build process runs just fine under macOS and Linux as well (Wine is downloaded and cached as needed).

Warning: for this to work, the favicon.ico can be a multiple-size version and it must include one version of at least 256x256 size.

@maximegris maximegris merged commit 0ce70b0 into maximegris:master Nov 18, 2017
@Lazza
Copy link
Contributor Author

Lazza commented Nov 20, 2017

An additional note that might be useful to someone: when running as a single EXE, the app is actually unpacked to a temporary directory so it runs from a different working directory. To figure out the directory containing the compressed portable app, you can do something like this:

var environment = require('process').env;
var pwd: string = environment["PORTABLE_EXECUTABLE_DIR"] || environment["PWD"];

@rm-code
Copy link
Contributor

rm-code commented Jan 25, 2018

The build process runs just fine under macOS and Linux as well (Wine is downloaded and cached as needed).

@Lazza I just tried packaging for windows via npm run electron:windows, but I get an error saying I don't have wine installed.

{ Error: 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.

See https://github.com/electron-userland/electron-packager#building-windows-apps-from-non-windows-platforms for details.
    at exports._errnoException (util.js:1020:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:197:32)
    at onErrorNT (internal/child_process.js:376:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn wine',
  path: 'wine',
  spawnargs: 
   [ '/Users/rmcode/Coding/RemateClient/node_modules/rcedit/bin/rcedit.exe',
     '/var/folders/b2/s7g7mh7918nfyr9kgff752_40000gn/T/electron-packager/win32-ia32/remate-client-win32-ia32/remate-client.exe',
     '--set-version-string',
     'FileDescription',
     'remate-client',
     '--set-version-string',
     'InternalName',
     'remate-client',
     '--set-version-string',
     'OriginalFilename',
     'remate-client.exe',
     '--set-version-string',
     'ProductName',
     'remate-client',
     '--set-file-version',
     '0.0.0',
     '--set-product-version',
     '0.0.0',
     '--set-icon',
     'src/favicon.ico' ] }

@Lazza
Copy link
Contributor Author

Lazza commented Jan 25, 2018

@rm-code the command I proposed with this PR is called winportable. The windows command is the "old" one which uses a different build tool.

@rm-code
Copy link
Contributor

rm-code commented Jan 25, 2018

My apologies ... I was going by the docs in https://github.com/maximegris/angular-electron#included-commands and didn't think to check the contents of your PR. It worked fine with the winportable flag 👍

@Lazza
Copy link
Contributor Author

Lazza commented Jan 25, 2018

No problem. 😄 Just keep in mind that electron-builder caches Wine inside $HOME/Library/Caches/electron-builder amounting to a whopping 240 MB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants