admin管理员组文章数量:1391964
I have a problem with AvaloniaUI on MacOS, where the dock icon isn't what I have specified, it's always an exec icon like that.
Changing the icon file doesn't help at all. I checked it and it's a MacOS problem, cause on Windows it's fine. It is possible to do it manually, but I would have to do it every time I build the app :(
I have a problem with AvaloniaUI on MacOS, where the dock icon isn't what I have specified, it's always an exec icon like that.
Changing the icon file doesn't help at all. I checked it and it's a MacOS problem, cause on Windows it's fine. It is possible to do it manually, but I would have to do it every time I build the app :(
Share Improve this question asked Mar 13 at 15:28 OstryJROstryJR 111 bronze badge1 Answer
Reset to default 0You have 2 options, manually -> every time you make a new build, or automatically:
It can be manually changed but you have to do it every time you build the app. To do that:
- Run the app
- Double finger click on the icon in dock ->
Options
->Show in Finder
- Double finger click on the icon in finder and choose
Get Info
/ click the icon and doCmd+I
- Drag&Drop the correct icon file onto the icon in the Top Left Corner of the Info window (to the left of the bold file name)
Or better way of doing that is to do it automatically:
Go inside your project, go to .csproj file, which contains all necessary build info for your app
after </PropertyGroup>
tag , add this code:
<Target Name="OnlyMacOSPostBuildChangeIcon" AfterTargets="PostBuildEvent">
<Exec Command="$(ProjectDir)changeIconmand $(ProjectDir)" Condition=" '$(OS)' == 'Unix' Or '$(OS)' == 'Darwin' " />
<!--<Message Importance="High" Text="The Icon of the app is changed now!" />-->
</Target>
It basically checks if the build machine is on MacOS, and runs the changeIconmand
file, which changes the icon, just after the app finishes building.
After that, create somewhere a file changeIconmand
and put inside this code:
#!/bin/bash
GLOB_PATH="$1"
ICON_PATH="$GLOB_PATH/path_to_your_icon.icns"
TARGET_PATH="$GLOB_PATH/path_to_the_executable"
cp "$ICON_PATH" /tmp/tempicon.icns
sips -i /tmp/tempicon.icns
DeRez -only icns /tmp/tempicon.icns > /tmp/tempicns.rsrc
Rez -append /tmp/tempicns.rsrc -o "$TARGET_PATH"
SetFile -a C "$TARGET_PATH"
echo "Icon changed successfully!"
This script basically copies the .icns icon file into temporary directory, makes sure that the icon has a proper resource fork, extracts icon data, and finally tells MacOS to use the custom icon.
Remember to change the paths for files:
path_to_your_icon
- path to icon file with .icns extension,
path_to_the_executable
- path to the exec file without extension, (usually something like /bin/Debug/netX.X/...
)
The paths should be from location where the mand file is
本文标签: Avalonia is not showing correct app icon on MacOSStack Overflow
版权声明:本文标题:Avalonia is not showing correct app icon on MacOS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744693706a2620151.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论