I'm building an Electron application and I've created a small daemon binary written in Go that is to be packaged along with the application as an extraResource
. However, there are different versions of this binary that need to be packaged depending on the platform, specifically, agent.exe
for Windows and agent
without the extension for MacOS, and for Linux, the same filename as Mac.
I have these binaries in the bin
directory in my project root:
├── bin/
│ ├── windows/
│ │ └── agent.exe
│ ├── mac/
│ │ └── agent
│ ├── linux/
│ │ └── agent
Testing for Windows, I included the bin/windows
directory, and it works fine (packages that exe in the resources directory as expected)
Here is the relevant snipped of my package.json
"build": {
"win": {
"icon": "build/app.ico",
"target": [
{
"target": "nsis",
"arch": [
"x64"
]
}
]
},
"nsis": {
"include": "build/installer.nsh",
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"license": "build/eula.txt",
"installerIcon": "build/app.ico",
"artifactName": "...",
"shortcutName": "..."
},
"extraResources": [
"bin/windows/agent.exe"
]
}
Is it possible to do this? As it is now, I would have to edit the package.json file by changing the extraResources
value in between different platform builds, which for obvious reasons is not ideal (as I could forget and wind up including the wrong binary by forgetting to change it back).
Note that I am not supporting 32-bit Windows, so all Windows builds would include the same (64-bit) binary.
I am using electron-builder 19.50.0