0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

プラットフォームごとに異なるアイコンを使用する際の注意点

Posted at

概要

MauiIconのIncludeにはそれぞれ別のリソースを設定すること
複数のMauiIconタグに同様のリソースパスを設定するとエラーが発生する

ダメな例

test.csproj

	<!-- App icon for Windows -->
    <MauiIcon Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'" Include="Resources\AppIcon\appicon.png" ForegroundFile="Resources\AppIcon\appiconfg.svg" TintColor="#40FF00FF" />

    <!-- App icon  -->
    <MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" TintColor="Yellow" />

エラー一覧(抜粋)

エラー	MAUI0000	System.IO.IOException: 別のプロセスで使用されているため、プロセスはファイル '<プロジェクトのパス>\obj\Debug\net7.0-windows10.0.19041.0\win10-x64\resizetizer\r\appicon.ico' にアクセスできません。

対策後

test.csproj

	<!-- App icon for Windows -->
    <MauiIcon Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'" Include="Resources\AppIcon\appiconforwindows.png" ForegroundFile="Resources\AppIcon\appiconfg.svg" TintColor="#40FF00FF" />

    <!-- App icon  -->
    <MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" TintColor="Yellow" />

※Includeに同じファイルパスを指定しなければ、問題ない

所感

とりあえず、変更前と同じように動くようになってよかった。
ただ、なぜ拡張子が異なっているのに同一ファイルのように扱われているのか等、不明なことは多い。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?