mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-07 05:37:20 +00:00
Publish Output Performance #1035
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @AeonSake on GitHub (Dec 12, 2025).
I have a few questions regarding the publish output which I couldn't really find an answer to so far:
app.asarfile (npx @electron/asar extract app.asar <dir>), or by settingasartofalsein theelectron-builder.jsonfile. The archive content underapp.asar/binseems to exist twice?node_modulesdirectory even required?Furthermore, the startup time from launching the app via the published .exe file seems rather large? Does it extract the content every time you open the app?
@FlorianRappl commented on GitHub (Dec 12, 2025):
node_modules. I know the issue and I have proposed a solution (bundling) beforehand. I will most likely implement this soon (definitely before the v1).That can definitely be. I have observed something more drastic (recursive cascade), but that has been a bug and should have been solved. Nevertheless, I think its a possibility we need to look into.
Yes - see above. Right now
node_modulesis required, but in the future that won't be the case any more.I don't think so, but the extraction part is not where most of the time is spend. In general exe files are slower if they are bigger. It's just that IIRC Windows reads them fully before running. Hence reducing the size will have beneficial initial load impact.
@AeonSake commented on GitHub (Dec 12, 2025):
After more testing, I can now definitely say that the
bindirectory is duplicated:resources/app.asar/bin(orresources/appifasaris disabled), which is required to runresources/binas unpacked content; this can be deleted without affecting the appI tested this in the following ways:
unpackeddirectory (win-unpackedon Windows) while the second directory was renamed/deletedRemoving the duplicate will already reduce the binary size by at least 100MB.
@AeonSake commented on GitHub (Dec 12, 2025):
Also regarding the unpacking, from the testing above, it really seems the app is unpacked every time the .exe is called. The temp directory is then deleted after the app is closed.
@AeonSake commented on GitHub (Dec 12, 2025):
For anyone that is concerned about bundle size, adding
<CompressionEnabled>false</CompressionEnabled>to the project configuration will disable thebrotliandgzcompression of static web assets that is turned on by default sincenet9.0. Compression serves no real benefit for local apps and unnecessarily duplicates static files in yourwwwrootdirectory (even if they are smaller after compression).Adding
"electronLanguages": [ "en-US" ]toelectron-builder.jsonwill remove all other locales from the output. Useful if you only use the electron shell as host and not show any other UI (or only target a select few locales).@softworkz commented on GitHub (Dec 12, 2025):
I don't see this. My app.asar file is <7 MB
Really?
resources/binis actually the place where the .net application lives. I've never seen it inresources/app.asar/binThis is only ONE specific kind of output. There are many others available. Start with
.zipfor further investigations.Though! I should note that everything I say is based on Linux targets - but there, it's true for all (deb, rpm, pac, tar.gz, AppImage)
@softworkz commented on GitHub (Dec 12, 2025):
Also, don't look at the
xxx-unpackedfolder. That's not a regular output.@AeonSake commented on GitHub (Dec 12, 2025):
Well, yes.
I'm currently using
portablefor the Windows build. I also triedzipas target, with the same result.app.asaris ~120MB in size, and next to it is thebindirectory, also with roughly 120MB. Extracting theapp.asarfile reveals that thebindirectory also exists within it.I get that, but the extracted content mirrors the content of the
win-unpackeddirectory. At least on Windows.@softworkz commented on GitHub (Dec 12, 2025):
Can you show your electron builder json?
@AeonSake commented on GitHub (Dec 12, 2025):
Pretty much the default:
@softworkz commented on GitHub (Dec 12, 2025):
Okay, I can confirm this duplication is happening - on Windows - not on Linux.
@hillin commented on GitHub (Jan 21, 2026):
I also find it helps a lot to clean up the bin folder before publishing.
@softworkz commented on GitHub (Jan 21, 2026):
The problem with Clean is that it only cleans the
bin/xxxoutput for the current configuration, and doesn't always remove everything. Also it doesn't clean theobj/xxxtrees - when something has gone wrong there, it doesn't help either.What I'm using all the time is a VS extension named "Super Clean" (there are multiple similar ones, but that's the best). Other than the MSBuild "Clean" target, it also doesn't clean dependencies but just the project(s) you have selected (before right-clickl >> Super Clean).
In the context of Electron.NET, it often shows a message about not being able to clean something in
node_modules(not the one in the project but the one in the build subtree). But the 2nd attempt usually succeeds. And when it succeeds (no message shown) you can be 100% sure that all bin and obj folders have been emptied (that's why I don't recommend the other extensions of that kind).