I am facing the following issue within a .NET MAUI app using .NET 8: I need to display different app icons depending on whether the app is compiled in Release or Debug mode. This allows for better control when working with them.
I declare the MauiIcon in the .csproj
file based on the selected build configuration:
<!-- App Icon -->
<MauiIcon Condition="'$(Configuration)' == 'RELEASE'" Include="Resources\AppIcon\appiconblack.svg" ForegroundScale="0.65" Generate="True" />
<MauiIcon Condition="'$(Configuration)' == 'DEBUG'" Include="Resources\AppIcon\appicon.svg" ForegroundScale="0.65" Generate="True" />
Up to this point, everything works well. The problem I cannot solve is how to dynamically apply the correct icon in the AndroidManifest
file:
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true">
</application>
I can't find a way to make the AndroidManifest
dynamically load the correct app icon based on the build configuration.
There is no need to change anything in AndroidManifest
. I have solution that should work for all platforms.
AppIcon
Folder, Debug
and Release
appicon.svg
<MauiIcon Condition="'$(Configuration)' == 'RELEASE'" Include="Resources\AppIcon\Release\appicon.svg" ForegroundScale="0.65" Generate="True" />
<MauiIcon Condition="'$(Configuration)' == 'DEBUG'" Include="Resources\AppIcon\Debug\appicon.svg" ForegroundScale="0.65" Generate="True" />
This should work without any issue.
Note: Do a Rebuild
before deploying the release and debug builds.