1
votes

I have a dll-file that I need to use for a separate process that is started by the Main process in my Electron project.

So I want to include this dll in my electron project and I'm using electron-builder to build the project. The problem is that I don't know how to include the file without it being added in the asar package, which is not reachable from the separate process directly. When I use app.getPath() to get the path for the running instance it will look something like this:

C:\installPath\myProject\resources\app.asar\my.dll

my electron-builder.json currently looks like this:

{
  "productName": "myApp",
  "directories": {
    "output": "release/"
  },
    "files": [
        "**/*",
        "my.dll"
    ],
  "win": {
    "icon": "dist",
    "artifactName": "myApp.${ext}",
    "target": [
      "portable"
    ]
  }
}

Are there any way to get my.dll included in the resources folder (or somewhere else) instead of in the app.asar?

Thanks!

2

2 Answers

1
votes

Solution1: You should be able to do it with "extraResources" param, put your .dll under resources folder, then create config param named "extraResources" under targeted dist.

The installation process should copy the file(s) to app’s resources directory

https://www.electron.build/configuration/contents#extraresources

Solution2: You can download .dll file from a web server then move it to the desired place with fs.

0
votes

If you Keep the DLL file in the Dist folder, Electron-builder tool will include that file into the app.asar file.

This is the limitation of that because if you trying to load the dll file using ffi module or your own written native node module then it will not load the file from app.asar file. so you have to keep the dll file outside of the app.asar file manually or make this copy setup part of your build system.