ruidfigueiredo/electron-cgi

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:

image

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