Closed julianpoemp closed 2 years ago
Hi @julianpoemp,
I think you meen packing your application.
You have two choices for that :
1) use option --plateform
in your packing command.
Exemple for windows and linux packing :
nx run <electron-app-name>:package --plateform=windows,linux
You can find all option on this page
2) use static packing configuration.
You can find exemple on this page You can find all options and détails on Electron Builder documentation Notice : Static configuration will overide the options you pass manually via the command line or choose via the angular console.
Hope this can help you.
Hi @naej56,
thank you for your fast answer 😄
I tried it using --platform
but it doesn't work. It still builds only the MacOS version.
I tried two different ways to pass the platform
argument:
In the build command:
nx run
After that hadn't worked I tried to append it in the angular.json file:
...
"package": {
"builder": "nx-electron:package",
"options": {
"platform": "windows",
"name": "<electron-app>",
"frontendProject": "<electron-app>",
"outputPath": "dist/packages",
"prepackageOnly": true
}
},
...
Both didn't work...
i have no way to test right now sorry.
But may be you could try with a config file .\apps\<electron-app-name>\src\app\options\maker.options.json
@naej56 no problem. I'm currently testing a possible solution. If it works, I'll write it here.
@julianpoemp multiplatform builds are not a trivial thing, especially on mac.
You will need to compile the program with the target machine instructions set. Which means you will probably need to invoke the packager inside a docker container/virtual machine/build server that runs your target platform.
You can find detailed explanation on this document.
I got it working with nx-electron. I had to install a 64bit version of wine on MacOS BigSur. Because --platform
falls to default while using prepackageOnly=true
I set it to false
for all platforms. I don't understand why this happens, but it works. Further more I had to set the base-href attribute to "./". Further more I had to set the "arch" and "target" attributes to the windows options in the maker.options.json
file. I can now build binaries for macOS, Windows and Linux on the same computer.
The command I'm using is:
nx build <frontend-app> --prod --base-href='./' && nx build <electron-app> --prod && nx run <electron-app>:package --platform=windows --prepackageOnly=false
Thank you for your help! 😃
I didn't knew Wine is an option one can use, nice. You should use the following command instead:
nx build <frontend-app> --prod --base-href='./' && nx build <electron-app> --prod && nx run <electron-app>:make --platform=windows
nx build
--prod --base-href='./' && nx build --prod && nx run :make --platform=windows
@bennymeg where does the platform
parameter come from?
All the executors have a schematic file (which is where the platform option comes from). The package executor have an additional schematic for the builder options.
I do not use the CLI, I use the API (which is poorly documented), you can find more information about the platform variable inside electron-builder
source files. (Platform, createTargets).
Okay, then I think it's like this:
pakage
and make
commands use the same executor named package
: https://github.com/bennymeg/nx-electron/blob/f89a13b586e16b5d3aec4b913494e4e7dd1b0232/packages/nx-electron/executors.json#L19-L21schema.json
file (for the arguments)The validation/maker.schema.json is used to validate the maker.options.json
file
Correct
This was not clear, could be made clearer in docs
I don't understand how to build the electron app to binaries for multi platforms. I'm using MacOS 11.6.2 and I would like to build a binary for windows and linux, too.
How can I do this using nx-electron and Angular?