Publish / build
Closed this issue ยท 4 comments
Can you provide any documentation or guidance on distributing apps created with electron-cgi. How to publish this app with .net code?
You can use electron-packager (or electron-builder, although I haven't tested it) to package your app.
The thing you have to be aware of is that the path you use in the ConnectionBuilder will change when the app is packaged.
So, if your dotnet app is next to main.js in a folder named DotNetApp, after you package your app with electron-packager the generated executable will be in a folder with a resources folder that inside will have an app folder that inside will have DotNetApp. (resources/app/DotNetApp)
Since this is predictable you can, for example, rely on environment variables to have ConnectionBuilder use one path at development time and another when the app is packaged.
Thanks for the quick reply, i really appreciate this but i still can't get it to work. I changed to path to the dotnet app. So my dotnet app is called dotnet-bridge and it is located in a folder called src. I changed the connection builder command to this
const connection = new ConnectionBuilder().connectTo("dotnet", "run", "--project", "resources/app/src/dotnet-bridge").build();
That error i get when executing the package (build with electron-packager) = Uncaught Exception:
Error: Could not start dotnet. Are you sure you have the right path?
Any ideas?
I tried it just now and this is what I got:
Run this:
npx electron-packager . tim_antonious_app --platform=linux --arch=x64
and dotnet-bridge ends up in tim_antonious_app-linux-x64/resources/app/dotnet-brigde, as highlighted:
.
โโโ dotnet-bridge
...
โโโ index.html
โโโ LICENSE.md
โโโ main.js
โโโ node_modules
...
โโโ package.json
โโโ package-lock.json
โโโ preload.js
โโโ README.md
โโโ renderer.js
โโโ tim_antonious_app-linux-x64
....
โโโ resources
โ โโโ app
โ โโโ dotnet-bridge <-----------------
.....
โ โโโ index.html
โ โโโ LICENSE.md
โ โโโ main.js
โ โโโ node_modules
โ โ โโโ @electron
โ โ โโโ @sindresorhus
โ โ โโโ @szmarczak
โ โ โโโ @types
โ โโโ package.json
โ โโโ package-lock.json
โ โโโ preload.js
โ โโโ README.md
โ โโโ renderer.js
โโโ resources.pak
โโโ snapshot_blob.bin
โโโ swiftshader
โ โโโ libEGL.so
โ โโโ libGLESv2.so
โโโ tim_antonious_app
โโโ v8_context_snapshot.bin
โโโ version
โโโ vk_swiftshader_icd.json
Also, you should use dotnet publish in your dotnet app so that you get an executable and don't have to rely on dotnet run
when you are ready to publish: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish?tabs=netcore21