-
-
Notifications
You must be signed in to change notification settings - Fork 726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Package Size and Optimization #157
Comments
For windows: #153 Linux still has issues. For getting smaller sizes I am currently trying to package the damn thing manually for distribution, if I use electron-builder for windows my installer sits around 65 ish MB. I am currently trying to bypass the build command for electronnet by doing the following: Build the application once using the command Then, there should be an directory within obj/Host containing just the electron application (folder contains main.js) Edit the package.json and change the name and version(in my case). then within that directory I run 'electron-builder build'. A dist directory appears in that directory with an (nsis) installer of about 65mb. Which works. Currently trying to get a linux build going on (AppImage fails without giving an explanatory error, deb file gives some package.json error, such as author name and emailaddress + homepage, etc. All required by a deb file. Some customization for the package.json file would be helpfull, like some kind of property file for custom package.json parameters so when the package.json file is being generated the values from the property file are added and or replaced within the package.json file. *Edit: I had an older version of electron-builder installed, apparently when building on windows for linux its using a remote builder, it failed on uploading the stuff to the remote builder. After installing the latest version the build seems to work for linux as well. Currently have a batch file that automatically generates a package.json file (DONT do this when you have custom dependencies installed) and a electron-builder.json file with the specific config for each package/platform. In case your interested I can provide the batch file. |
@EldinZenderink Thank you SO MUCH! |
Its ugly AF (my first try at writing an actual batch script ;) ) but here it is: Just put these files in your root project folder. For help, type ./build.bat help Just replace the values within package.json & electron-builder.json to the values you want (highly recommend to use the wiki of electron-builder, you can leave the linux target in there even if you dont want linux, if you specify that you only want to build windows (see the help) it will ignore the linux target. Hope it helps. *Btw linux packaged deb files are not working in my case, it's giving me an anoying ENOENT for both AppImage and deb files and neither Icons are visible, so, or my script is doing something weird, or the target setup is wrong, I will keep experimenting. *Oh and you do need to in stall electron-builder globally! *Btw the script expects a full file path, so nothing relative. |
You are awesome! Thank you again. |
BTW, I made a stupid mistake, depending on which os you want to build, you need to run the |
@srameh |
@EldinZenderink: |
@EldinZenderink The app runs fine when running electronize start and also when running the version built from Any ideas? |
As mentioned in my post above, you can't use the Host directory most of the time. (Mine for some reason did work when using the Host directory, but only for the platform that I build upon, but that might just have been a stroke of not helpfull luck). So when performing the 'dotnet electronize build command' you need to use the Also when installing to the Program Files directory, you might need to run it with admin rights, depending on what your back-end does. I do need to mention that in the end I gave up on getting it to work (icon issues and all that as well) with ElectronNET. ElectronNET is cool, especially if you need to use the API from electron directly from the back-end, but I didn't need that. In my case I manually created a electron project, added a directory for my .net core back-end and interface, moved my back-end to that directory after publishing it (creating an executable). Then I just initiate a child process within main.js (nodejs stuff) from electron. For my interface, since my interface is a standalone single page (typescript/angular 5) webpage I just directly load it in. (Or you could load the url of your back-end if that is what you desire). And it works fine. I then can just use electron-builder to package it without any issue (you need to replace the back-end stuff when compiling for a different platform such as linux with a published backed with target linux). |
Oh sorry I missed that. I have also tried to do this by performing the build command and trying to use your scripts in the following location From what I have seen online I have also been running |
I suppose the biggest thing I can notice. After the package is installed using the installer from electron-builder there is no Because when the command |
This is the error I receive:
|
@RogerDodger123 spawn error generally means that there is an issues "spawning" the process runing your .net core application. Again, did you try using the /obj directory? Another thin you can try and can do is the following: go to the installation directory, try to find the location of the main.js file (dont know it out of my head) (and make sure you asar disabled before packaging the installer), install electron globally, and then run through cmd: |
Oh btw, my bad, in the electron builder json file i didnt add the |
I have just tried to use your bat file to create the installer from the obj directory but I am getting errors from the electron-builder process. Think I may have other issues aside from this. Will check back when I get somewhere. Thanks |
@EldinZenderink |
Asar is like a zip file containing the files for electron to run. When turning on asar it will also package the .net core backend within the same asar file. But what electron does is just spawn a child process running the back-end like you normally would when clicking on it (just automatically). (And some more magic by ElectronNET to make the API work). But when you pack the backend within the same asar file, the path to the executable for the backend is no longer correct (like normally it would be something like this: ./a/path/to/the/backend/, but when asar is used, it should be something like this: ./app.asar/a/path/to/the/backend/) You can however specify (using electron-builder) which files should be extracted out of the asar file first, but since I don't mind not using asar I just leave it like this. Though I guess asar makes the package smaller or something, haven't really looked it up yet. |
I have looked into this abit more and went through electron packaging doc. I have got it working now by unpacking the .exe like suggested in your post and making a slight change to the main.js to counter for the different file location. Thanks for your help |
No problem, glad to be of help. |
Something I have realised... after performing This is without making any changes to files to do with the asar issue I was having. |
I think it has to do with running development mode and release mode(which is after packaging) (might be completely wrong here). If you go to the directory where normally the main.js is located, and run the |
That make sense!!! Thanks again. |
@robertmuehsig can you do that for the CLI? |
This would be very nice if we can compress the sizes more. In this fact we also need less time to load the programs. If you compare javascript electron implementation it needs for a empty running programm only 80mb of ram but Electron.Net for exactly the same needs 240-255mb Ram. |
We have been switching to electron builder since version 5.22.12. That creates an extremely compact version. At a startup performance will continue to be intensified. |
I have successfully built an application using MVC Core 2 and SQLite. After running the BUILD command I noticed the following issues:
The size of the build folder is 360MB. This is huge for simple MVC app.
The app launch time is very slow. It takes about 20-30 seconds before you see the window.
The Application name defaults to ElectronNET.Host. This value is coming from package.json which is generated by the Electron.net.
The App icon defaults to Electron icon. Passing new icon path as part of the build command parameter did not help.
How can I include my own package.json file so it does not take the name ElectronNET.Host?
How can I reduce the size of the application and fix the above issues?
The text was updated successfully, but these errors were encountered: