Avalonia.FuncUI
Avalonia.FuncUI copied to clipboard
Getting the window icon working (MacOS)
I've been trying to figure out how to get my gui's window icon to register within the system dock within MacOS. I would like to get it working on all platforms, however I wasn't sure if there were extra quirks to MacOS that I was missing. This also seems like a good thing that could be added to the examples and templates for reference for people picking up the project for the first time.
Shell.fs
type MainWindow() as this =
inherit HostWindow()
do
base.Title <- "Title"
base.Width <- 600
base.Height <- 400
base.Icon <- WindowIcon "avares://Gui/Assets/Icon.ico"
this.HasSystemDecorations <- true
Gui.fsproj
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<AvaloniaResource Include="**\*.xaml" />
<AvaloniaResource Include="Assets\*.ico" />
</ItemGroup>
...
</Project>
I had also tried this without success
type MainWindow() as this =
inherit HostWindow()
do
base.Icon <- WindowIcon "Assets/Icon.ico"
<None Include="Assets\*" CopyToOutputDirectory="PreserveNewest" Link="Assets" />
Could you take a look at the PR #185 and try out the same approach? The submitter mentions having the same problem of the icons not being correctly picked up by the Avalonia resources on Windows as well, so seems like it's not only happening on Mac.
Still it'd be interesting to take a further look to see if this is an issue with FuncUI or Avalonia itself.
It looks like he was using the following approach, using the Content container instead of None and using the CopyToOutputDirectyory subelement instead of a data block. This didn't give any difference in results unfortunately.
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<Content Include="Assets\Icons\icon.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
...
</Project>
By the way, just wanted share the screenshot of the current state of the icon for reference

I'm seeing this issue https://github.com/AvaloniaUI/Avalonia/issues/2649 and this pull request to avalonia https://github.com/AvaloniaUI/Avalonia/pull/6560 although it looks like it was merged into Avalonia 0.10.10
Edit:
I upgraded to Avalonia.FuncUI 0.5 which and Avalonia 10.11 and this did not solve the issue
For macOS I believe you need to create an app bundle that includes an .icns icon for it to work.
https://docs.avaloniaui.net/docs/distribution-publishing/macos
@iminashi Thanks, this seems to be the right road to go down. I tested my previous attempts on Linux and I'm able to get the icon working. I haven't gotten it working on Mac yet but I anticipate that with some more work and the Avalonia publishing guide, I should get there