Skip to content

feat: windows app icon#3753

Merged
jkelleyrtp merged 15 commits intoDioxusLabs:mainfrom
Klemen2:windows-app-icon
Apr 22, 2026
Merged

feat: windows app icon#3753
jkelleyrtp merged 15 commits intoDioxusLabs:mainfrom
Klemen2:windows-app-icon

Conversation

@Klemen2
Copy link
Copy Markdown
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
@jkelleyrtp jkelleyrtp added the cli Related to the dioxus-cli program label Apr 9, 2025
@photino
Copy link
Copy Markdown
Contributor

photino commented Apr 26, 2025

Why didn't previous versions support Windows app icons?

@Klemen2
Copy link
Copy Markdown
Contributor Author

Klemen2 commented Apr 26, 2025

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

Comment thread packages/cli/src/build/request.rs Outdated
Comment thread packages/cli/src/build/request.rs Outdated
Comment thread packages/cli/src/build/request.rs Outdated
@Klemen2
Copy link
Copy Markdown
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

@pythoneer
Copy link
Copy Markdown
Contributor

pythoneer commented Oct 21, 2025

Anything left i can help with to bring this over the finish line? 0.7 is is nearing its release and i would love to not use a workaround for my current releases with 0.6 to have app icons.

@Klemen2
Copy link
Copy Markdown
Contributor Author

Klemen2 commented Oct 21, 2025

Anything left i can help with to bring this over the finish line? 0.7 is is nearing its release and i would love to not use a workaround for my current releases with 0.6 to have app icons.

There are a few changes that needs to be done.

  • 1. testing bundling apps for windows on mac/linux
  • 2. It should probably not fail to build for windows if you do not have the tooling, it should only fail for bundling and release builds this requires changing how default icon is handled on windows (embedded with include_bytes instead of loaded from_resource) and if that's the case notify the user that there will be no icon for the app
  • 3. Make it work with workspaces, since currently it doesn't compile unless you cd to the app crate itself (e.g will not work with 👩‍🏫 Add support for default-members #4811) - there should probably be a test for this so you see that it fails
  • 4. I noticed that the logs "Compiling Windows resource file with ..." gets outputted twice, it should just be once
  • 5. default icon handling for other platforms (related to 2. but ideally it would get it from the app itself and fallback to include_bytes for non release/bundle) -- not required for this PR, but would be nice for consistency
  • 6. caching the windows resource file so it only compiles when the associated files changes -- not required for this PR

I think this is everything unless @jkelleyrtp has anything to add, feel free to work on this

@Klemen2
Copy link
Copy Markdown
Contributor Author

Klemen2 commented Oct 21, 2025

microsoft has since added windows-resource to crates, but before they release anything it will be another half a year or more or it may not even be related to the resource compiler based on their sense of naming things

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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

@jkelleyrtp
Copy link
Copy Markdown
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

@Klemen2
Copy link
Copy Markdown
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

@jkelleyrtp jkelleyrtp modified the milestones: 0.7.0, 0.8.0 Jan 23, 2026
@pythoneer
Copy link
Copy Markdown
Contributor

relevant PR #5328

Comment thread packages/cli/src/build/request.rs Outdated
@pythoneer
Copy link
Copy Markdown
Contributor

pythoneer commented Apr 9, 2026

I think #5412 and #5328 caused conflicts again. Not sure how this affects this PR :(

@jkelleyrtp
Copy link
Copy Markdown
Member

Would love to merge this. What's the current state?

After digging into windows bundling recently, I have several thoughts:

  • dx bundle shells out to wix / nsi which have options to include icons. For many users this could just be enough? You don't get icons during dev, but you do in bundle, which is really what matters.
  • There is a crate called sui which lets you inject icons and files into binaries after they've been built (https://github.com/denoland/sui). This might be pretty simple.
  • We can just add the icon via the linker - ie dx runs cargo rustc -- -C link-arg=app.res automatically. I think that's what's happening in this PR?

It seems that on many platforms we need some sort of pre-processing step for icon generation (android as well, and mac/ios). This adds extra overhead in dev (slower dev-server starts until we properly parallelize things), which is why we've deferred it to bundle.

I'm happy to add this step in dev too if folks think it's important.

Copy link
Copy Markdown
Contributor Author

@Klemen2 Klemen2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, wix / nsi settings only add icon to the installer, not the actual app.
the pr is basically doing cargo rustc -- -C link-arg=app.res where res needs to be compiled with rc.exe (or equivalent) because windows is special.

I don't think that dev builds necessarily need an icon, so atm you just get a warning if it can't be compiled.

I think that I only need to update a couple of things which I can probably do this weekend.

Comment thread packages/desktop/src/default_icon.rs Outdated
Klemen2 added 4 commits April 11, 2026 12:41
I don't think it's a good idea to do
[default.extend-words]
fo = "fo"

 as it's a very common mispelling for 'for'
@Klemen2 Klemen2 changed the title feat: windows app icon + default icon from toml feat: windows app icon Apr 11, 2026
Klemen2 and others added 6 commits April 17, 2026 12:00
fix the amazing merge
renamed winres to windows
moved windows winres build request to windows
@Klemen2
Copy link
Copy Markdown
Contributor Author

Klemen2 commented Apr 21, 2026

I'd say this is ready, unless you want any changes in the windows scope.

@jkelleyrtp
Copy link
Copy Markdown
Member

Thanks so much!

@jkelleyrtp jkelleyrtp merged commit 3f82c45 into DioxusLabs:main Apr 22, 2026
21 checks passed
@Klemen2 Klemen2 deleted the windows-app-icon branch April 22, 2026 13:05
@adamgreg
Copy link
Copy Markdown

adamgreg commented May 5, 2026

The addition of ApplicationConfig::name in this PR is very interesting! It looks like it's not really used yet, but is it intended as a way to override the application name in bundles, so it doesn't have to be a PascalCase version of the crate name? That would be really useful for my app.

Is anyone working on that? I couldn't find an open PR. I'd be willing to give it a try myself if that would be welcome.

@Klemen2
Copy link
Copy Markdown
Contributor Author

Klemen2 commented May 5, 2026

right now it's only used for the windows product name (app -> right click -> properties -> details)
the app name is not yet affected but fell free to implement it

@adamgreg
Copy link
Copy Markdown

adamgreg commented May 7, 2026

right now it's only used for the windows product name (app -> right click -> properties -> details) the app name is not yet affected but fell free to implement it

FYI I just raised #5533 for this

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

6 participants