electron-builder
electron-builder copied to clipboard
Package two different version application prod and staging
- Electron-Builder Version: 22.10.5
- Node Version: 14.16.0
- Electron Version: 11.0.1
- Electron Type (current, beta, nightly): current
- Target: Windows
Hi, all! I have application electron-react. I try to build two differnt version application and if install prod version he reinstall staging version. How to do it?
appid different for prod and staging.
electron-builder-prod.json
{ "productName": "Name", "appId": "com.prod.application", "files": [ "dist/", "node_modules/", "index.html", "main.prod.js", "main.prod.js.map", "package.json" ], "afterSign": ".erb/scripts/Notarize.js", "mac": { "target": [ "dmg" ], "type": "distribution", "hardenedRuntime": true, "entitlements": "assets/entitlements.mac.plist", "entitlementsInherit": "assets/entitlements.mac.plist", "gatekeeperAssess": false }, "dmg": { "contents": [ { "x": 130, "y": 220 }, { "x": 410, "y": 220, "type": "link", "path": "/Applications" } ] }, "publish": { "provider": "generic", "url": "/releases/prod" }, "win": { "target": [ "nsis" ] }, "linux": { "target": [ "AppImage" ], "category": "Development" }, "directories": { "app": "src", "buildResources": "assets", "output": "releases/prod" }, "extraResources": [ "./assets/**", "./src/resources", "./changelogs", ".env" ] }
electron-builder-staging.json
{ "productName": "App Insiders", "appId": "com.staging.application", "files": [ "dist/", "node_modules/", "index.html", "main.prod.js", "main.prod.js.map", "package.json" ], "afterSign": ".erb/scripts/Notarize.js", "mac": { "target": [ "dmg" ], "type": "distribution", "hardenedRuntime": true, "entitlements": "assets/entitlements.mac.plist", "entitlementsInherit": "assets/entitlements.mac.plist", "gatekeeperAssess": false }, "dmg": { "contents": [ { "x": 130, "y": 220 }, { "x": 410, "y": 220, "type": "link", "path": "/Applications" } ] }, "publish": { "provider": "generic", "url": "/releases/staging" }, "win": { "target": [ "nsis" ] }, "linux": { "target": [ "AppImage" ], "category": "Development" }, "directories": { "app": "src", "buildResources": "assets", "output": "releases/staging" }, "extraResources": [ "./assets/**", "./src/resources", "./changelogs", ".env" ] }
package.json command
"build-prod": "concurrently \"yarn build:main\" \"yarn build:renderer\"",
"build-staging": "concurrently \"yarn build-staging:main\" \"yarn build-staging:renderer\"",
"build:main": "cross-env NODE_ENV=production DEBUG_PROD=true webpack --config ./.erb/configs/webpack.config.main.prod.babel.js",
"build:renderer": "cross-env NODE_ENV=production DEBUG_PROD=true webpack --config ./.erb/configs/webpack.config.renderer.prod.babel.js",
"build-staging:main": "cross-env NODE_ENV=development DEBUG_PROD=true webpack --config ./.erb/configs/staging/webpack.config.main.staging.babel.js",
"build-staging:renderer": "cross-env NODE_ENV=development DEBUG_PROD=true webpack --config ./.erb/configs/staging/webpack.config.renderer.staging.babel.js",
"package-staging": "rimraf -rf src/dist && yarn build-staging && electron-builder build --publish never --config electron-builder-staging.json",
"package-prod": "rimraf -rf src/dist && yarn build-prod && electron-builder build --publish never --config electron-builder-prod.json",
`
That's quite bizarre indeed. I would have expected it to just be keyed off of the package appId
Maybe this may need to be different values between your stage and prod?
guid String | “undefined” - See GUID vs Application Name. https://www.electron.build/configuration/nsis
@mmaietta thanks, after config, problem was resolve. But i have new problem, two different package have same localstorage and indexeDB. It feels like they're running the same app even though they're in different directories.
Sorry, I have no idea why that would be happening. If you app has different names, different app IDs, and different GUID, I don't understand how it could be using the same file path within Users/<user>/AppData :/
I'm trying to do the same, with different build.appId, build.productName and build.extraMetadata.name, in the builder config file, which installs in different folders with different app names.
However, when I try to open the apps simultaneously, they get identified as the same app, and just maintain the old instance running instead of opening a new one (with the other build icon and name).
I think the key would be in the package.json productName. It says it is not required, but if I don't add it the app does not start at all, and if I change it to anything other than what is today, it cannot find webpack's code-splitted files.
If I use extraMetadata.productName it is the same behaviour; the app won't run with missing files (it does not matter if I add them to build.files)
I can uninstall and reinstall and they do not interfere with each other (as it happen if package.json name are the same)
In the task manager I can see that both builds have different names, what gives it away is electron-log. The path to the log is the same as prod for stating. So it is using package.json's productName for the app name and build.productName is not being used by electron, it seems to be just the name of the executable.
So at the end of the day, I have two executables in different folders with different names, appId, icons, etc, but somehow with the same "name", thus allowing only one instance to run at a time. They get recognized as the same app at runtime.