Don't support setting icon on windows
This is a very good packaging tool,but does not support icon settings on windows system.What should I do if I want to set it?
no it's not support icon on windows, you can use this project to set icon after build your exe
RisohEditor also looks like a good option for settings icons on Windows.
Another option is https://github.com/electron/rcedit I'm using it successfully with wine on my jenkins to set windows icon.
@karlsabo I've had a look around and found that Eclipse's icon setting tool for Windows looks promising since it is made in pure Java. It would be nice to list the possible ways of implementing icon support in Packr. I'm not too sure about how it works on Linux.
Yeah, a comprehensive list in the README would be great. That Eclipse code looks promising, I wonder if it's published as a JAR to a Maven repository somewhere, could make the work pretty straight forward.
That Eclipse code looks promising, I wonder if it's published as a JAR to a Maven repository somewhere, could make the work pretty straight forward.
It seems to be published, it's in there: https://mvnrepository.com/artifact/org.eclipse.platform/org.eclipse.equinox.p2.publisher.eclipse/1.3.700
Might be worth trying it out.
I've tried Eclipse's IconExe and apparently it replaces existing icons of a .exe file. It can't add icons, it just replaces. Is there any way we can generate the launcher executable with placeholder icons so that IconExe can replace them later?
@petoncle I don't have any experience with it, but I'm sure there's a tool we could run to set one by default.
@karlsabo There is a tool called windres which can add icons to a Windows .exe that doesn't have any icon. This is the tool that RisohEditor uses behind the scenes. It is part of GNU Binary Utilities (that page includes a link to their Git repository with the source code of windres). It looks like this tool can be compiled to run on Windows, Linux and Mac.
If windres can indeed run on all 3 OSes, maybe we could ship its binaries in packr-all (all 3 versions of it, one per OS) and have Packr run it to set the icon of the Windows launcher?
@petoncle, it's worth trying, there might be issues on macOS with gatekeeper. I'm not sure macOS would let us run an executable that isn't signed and notarized.
A Java solution would have been ideal.
@karlsabo If we can't ship windres, then we can try to use it when building the launchers for packr-all, and then use Eclipse's IconExe to swap the icons. The only thing I am not a fan of is that IconExe can only swap icons. We need to put placeholders icons in the Windows launcher and then ask the user to provide an .ico file that contains icons of the same size that we used for the placeholders. For example:
- We build a launcher that contains 9 placeholder icons: 16x16, 24x24, 32x32, 48x48, 64x64, 96x96, 128x128, 192x192, 256x256.
- When running packr-all, the user must provide an .ico file that contains 9 images of the same size as the placeholders.
If the user's .ico file contains less than 9 images or if one of the image doesn't match the size of the placeholders, the resulting .exe will contain the user's icons that IconExe was able to match and placeholder icons that IconExe was not able to match.
Or we simplify it and we use only 1 size (256x256) instead of 9, and let Windows downscale it. Not sure if that looks good in practice, but maybe it does. And then the user only has to provide this one 256x256 image.
my contribution to this talk : I tried to use perl with Win32:Exe Like any others tools named on this thread, it doesn't work as expected because, on non windows system, it could not create the resource section needed
use lib 'inc/';
use Win32::Exe;
$exe = Win32::Exe->new('my.exe');
$exe = $exe->create_resource_section if $exe->can_create_resource_section; //only work on windows
$exe->set_single_group_icon('../resources/windows64/icon_desktop.ico');
$exe->write;
so if the default exe could include a (empty) resource section, update/add an icon would be doable For now, I used ResHacker on a generated exe and I use this exe to overwrite generated one on every build, not a perfect solution unfortunately because I could broke something.
==== I also tried to create a reshacker version for OSX with Winery but an 1Go+ exe isn't suitable ;)
Why isn't this fixed? What use is there of being able to deploy on Windows if you can't set an icon?
PRs are welcome. Also there's jpackage.
I found no easy java library to do this on windows. I'm currently doing it on my Linux build Server using a CLI tool.