I am developing an electron application where I am using external .exe files. In development mode application works fine.
But when I package the application, it is unable to find those .exe files.
How to include .exe files in packaged application. I am using electron-builder for packaging.
Below is my configuration,
"build": {
"appId": "com.f.quickstart",
"files": [
"app/build/**/*",
"app/build/**/*.exe",
"main.js",
"mainIPC.js",
"src/**/*",
"dist/**/*",
"node_modules/**/*",
"package.json"
],
"win": {
"target": "portable",
"signAndEditExecutable": false
},
"linux": {
"target": "AppImage"
},
"mac": {
"target": "zip"
}
}
Looking for help.
Thanks
Related
I have successfully set icon for my electron app on MacOS and Windows OS with the icon file in the build folder, configuration on the package.json.
"build": {
...,
"mac": {
"icon": "build/icon.icns"
},
"win": {
"icon": "build/icon.png"
},
"linux": {
"icon": "build/icon.png"
},
},
However the linux platform seems to not working.
I also try to create the icons folder inside the build folder(./build/icons) as documented https://www.electron.build/icons.html which then paste the 512x512.png icon to there but nothing change after building the app.
I have an electron app which I would like to automatically update and to do that I am using electron-updater. It seems all the working parts are together but I cannot have the Release Notes. Here's my script to package and upload it to S3.
"package": "electron-builder build --publish always",
And here's my build
"mac": {
"category": "my.category.app",
"target": [{
"target": "dmg",
"arch": [
"arm64",
"x64"
]
}, {
"target": "zip",
"arch": [
"arm64",
"x64"
]
}],
"type": "distribution",
"hardenedRuntime": true,
"gatekeeperAssess": false,
"publish": {
"provider": "s3",
"bucket": "my-bucket-name",
"publishAutoUpdate": true
}
},
Now when I run the package, it packages the app and uploads it in my S3 bucket. I can see that all the zip, dmg and blockmap files for both x64 and arm64 are already uploaded and in addition to them, I also have the latest-mac.yml file.
When I run the app on dev, I can see that it recognizes that there is an update available and it downloads it automatically and when it is already downloaded, I can see that there is no release notes in the latest-mac.yml file. But I would like to have that as well so I can display it to my users before they accept to install it.
Any idea how to do that? Really appreciate it.
When I extract the app.asar inside the builded Mac app with:
npx asar extract app.asar destfolder
I can see that it includes mostly everything which is in my project folder.
How can I exclude the files from app.asar?
This are parts of my package.json: (because its too much code for stackoverflow)
"directories": {
"buildResources": "resources"
},
"extraResources": [
"./content/**",
"settings.json",
{
"from": "resources/icon.png",
"to": ""
},
{
"from": "resources/${os}",
"to": "../"
},
{
"from": "binaries/${os}",
"to": "binaries",
"filter": [
"**/*"
]
}
]
This is my project folder:
And this is the content of the builded app.asar file:
It seems I have to exclude every folder I dont want in the app.asar in the build section of the package.json like this:
"build": {
"files": [
"!binaries/**/*",
"!mac-build/**/*"
],
I'm cresting electron app using node-canvas.
I generated an app-installer by the following command:
$ electron-builder --mac --x64 --config ./build_mac.js
build_mac.js
const config = {
"appId": "jp.maplat.editor",
"asarUnpack": [
"assets/mac/canvas"
],
"directories": {
"output": "dist"
},
"files": [
"assets/mac",
"backend",
"css",
"frontend/dist",
"html",
"img",
"locales",
"package.json",
"package-lock.json",
"tms_list.json"
],
"afterSign": "script/notarize/notarize.js",
"mac": {
"icon": "assets/mac/icon_mac.icns",
"target": [
"dmg"
],
"hardenedRuntime": true,
"gatekeeperAssess": false,
"entitlements": "script/notarize/entitlements.mac.plist",
"entitlementsInherit": "script/notarize/entitlements.mac.plist",
},
"win": {
"icon": "assets/win/icon_win.ico",
"target": "nsis"
},
"nsis":{
"oneClick": false,
"allowToChangeInstallationDirectory": true
}
};
module.exports = config;
But after installing the electron app, the app outputs following error message on web console:
Uncaught Error: dlopen(/Applications/MaplatEditor.app/Contents/Resources/app.asar.unpacked/assets/mac/canvas/build/Release/canvas.node, 1): Library not loaded: /usr/local/opt/pixman/lib/libpixman-1.0.dylib
Referenced from: /Applications/MaplatEditor.app/Contents/Resources/app.asar.unpacked/assets/mac/canvas/build/Release/canvas.node
Reason: no suitable image found. Did find:
/usr/local/opt/pixman/lib/libpixman-1.0.dylib: code signature in (/usr/local/opt/pixman/lib/libpixman-1.0.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
How to solve this?
I think there are 2 issues,
How to sign this dylib?
This dylib looks installed under "/usr/local/opt", it is out of the application folder. Is this correct expected behavior?
Does anyone have the answer for this?
The solution to fix this is put all dylibs (except under "/usr/lib" or "/System/Library/Frameworks") under the folder which is in under control of electron.
Something like this in my project:
https://github.com/code4history/MaplatEditor/tree/master/assets/mac/canvas/build/Release
But just putting dylib is not working, because each dylib has information about link to other libraries.
You can check which libraries are linked from each dylib by using "otool" command, and youcan overwrite it by using "install_name_tool" command.
https://github.com/code4history/MaplatEditor/blob/master/mac_canvas_dylib
In this URL, you can find what I did for my project.
I use electron-forge and WIX to build installer on Windows. But I found that if there is a version number specified in package.json, then the installed folder will contain a subfolder with this specific version number appended.
For instance, if the version is "1.2.3+4", then inside the installed folder we get
app-1.2.3+4
This is problematic if we install new versions onto the same folder, which will litter all the old version files/folders in the same parent folder. I'd love new versions to simply overwrite that folder. How to get rid of this version number from the subfolder without affecting the versioning elsewhere?
Here is my wix setup inside package.json
"makers": [
{
"name": "#electron-forge/maker-wix",
"platforms": [
"win32"
],
"config": {
"arch": "x64",
"appUserModelId": "com.company.myapp",
"description": "description of myapp",
"exe": "myapp",
"appIconPath": "C:\\Temp\\myapp.ico",
"language": 1033,
"manufacturer": "mycompany",
"name": "My App",
"programFilesFolderName": "MyApp",
"shortName": "myapp",
"shortcutFolderName": "My App",
"ui": {
"chooseDirectory": true,
"images": {
"background": "C:\\Temp\\background-orange.png",
"banner": "C:\\Temp\\banner-orange.png"
}
},
"version": "1.2.3+4"
}
}
]
}
},