Skip to content

Conversation

@Klemen2
Copy link
Contributor

@Klemen2 Klemen2 commented Feb 16, 2025

image

Closes: #3648
Implement #3596 for windows

Windows app resources will only be build with --release flag, otherwise it will be embedded (no app icon (thumbnail) or metadata when installed)

This pr also reduces the binary size since including icon is now deduplicated.

Added functions: default_icon, icon_from_memory, icon_from_path

Tested only on windows 11

@Klemen2 Klemen2 requested a review from a team as a code owner February 16, 2025 20:26
Building with winres is now mandatory since app may build but fail to run due to how default icon for window is managed

- fixed default bundle icon path fail for windows
@jkelleyrtp jkelleyrtp added the cli Related to the dioxus-cli program label Apr 9, 2025
@photino
Copy link
Contributor

photino commented Apr 26, 2025

Why didn't previous versions support Windows app icons?

@Klemen2
Copy link
Contributor Author

Klemen2 commented Apr 26, 2025

windows is windows and always needs something special, aka building a resource file with a specific program

@jkelleyrtp jkelleyrtp added this to the 0.7.0 milestone Jul 1, 2025
Klemen2 and others added 4 commits August 12, 2025 13:35
changed bundle_dir to build_dir
since the app icon is expected, winres should also be expected to avoid successful builds with the app not launching because of that
@Klemen2
Copy link
Contributor Author

Klemen2 commented Aug 12, 2025

In the docs somewhere there should be a notice that windows is very bad at updating app icons of installed apps, so if you bundle the app, install it, change the icon and bundle again and reinstall - it will look buggy with old icon in some places and new one on other, with the only fix being restarting the pc or at least restarting the explorer didn't seem to fix it on my machine

1. fix winres for workspaces
2. winres will only be created for --release flag
This reverts commit ff109fe.
added icon_from_memory and icon_from_path helper functions for setting icons
@Klemen2 Klemen2 changed the title feat: windows app icon + windows default icon from toml feat: windows app icon + default icon from toml Oct 29, 2025
@Klemen2
Copy link
Contributor Author

Klemen2 commented Oct 29, 2025

I think that this is pretty much finished now. From the comment above 1. is probably out of scope but should work if you have the tools setup correctly,
4. is not a big issue and I don't really know why is happening
6. would be nice to have, but not really important

@pythoneer
Copy link
Contributor

I think the work here is relevant #4958 idk.

dan-da added a commit to Neptune-Crypto/neptune-proton that referenced this pull request Nov 29, 2025
This is a temporary fix until dx bundle is fixed.  See:
DioxusLabs/dioxus#3753

closes #8
@pythoneer
Copy link
Contributor

This PR #5072 worked on the same code location and created a conflict.

Klemen2 and others added 4 commits December 11, 2025 21:15
removed some cfg!(windows) for build.triple.operating_system
canonicalize_icon_path now checks if the path is absolute or from workspace

tauri bundler does not support AppList icon, it requires .ico
@jkelleyrtp
Copy link
Member

jkelleyrtp commented Jan 20, 2026

Sorry this has sat so long. I'm just not a fan of the winres approach.

Deno built a crate called sui which can embed resources into binaries after they've been built.

https://littledivy.com/sui.html
https://github.com/denoland/sui

It specifically handles embedding icons into PE (windows exe files).

I would prefer we use sui to embed the icon for windows instead of the build.rs / winres system.

Alternatively, we could perform the compilation of the icon in the CLI and then pass it in as a linker arg.

https://claude.ai/share/b0f8e502-2932-4734-b4b0-da1241a262c1

I just don't want icon configuration to be done from within the build.rs. The dioxus.toml should be the source of truth for these configuration options and dx should perform the linker flag modifications if needed.

// ❌
println!("cargo:rustc-env=DIOXUS_APP_ICON=./assets/default_icon.png")

I might also just be misunderstanding the PR. It seems that the inlined winres system has code for printing link statements and reading the cargo_manifest_dir, which I don't think is applicable here

https://github.com/klemen2/dioxus/blob/2322b03a74b1b13e53327d803cd20ea0255b3091/packages/cli/src/build/winres.rs#L782-L786

Added known Properties struct for better distinguishment between what windows will display and what it may not

Remove comments and functions that do not apply to this modified version
WindowsResource struct now only contains resource and not paths
Now it actually matches the target and not the cli build host
other platforms do not have default icon now
@Klemen2
Copy link
Contributor Author

Klemen2 commented Jan 21, 2026

winres was already doing compilation of the icon in the cli and was not using any cargo / build script since the first working version of this PR - basically what cloud suggested, the original was based on the tauri winres but this version is without embed_resource since it prints to the console, the tooling finder is from the script that zed is using winresource, I removed a bunch of irrelevant comments and unused stuff and also changed the structure a little

I haven't tested the gnu toolkit or on other platforms, only mscv on windows only

println!("cargo:rustc-env=DIOXUS_APP_ICON=./assets/default_icon.png") was done so that #3596 could be closed - now it's only implemented for windows, there is probably a better way of doing that on other platforms instead of embedding the icon in the exe but sui could be used for quick implementation, but I would need to look into it how and where it can be implemented

default_icon is not implemented on all platforms, remove not used cli const
@jkelleyrtp jkelleyrtp modified the milestones: 0.7.0, 0.8.0 Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to the dioxus-cli program

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Icon option in Dioxus.toml does not work on Windows

5 participants