I am creating a MAUI project that supporting iOS and Android platforms.
The .csproj of project need to distinguish iOS and Android when using different type of source.
There is a shared way from official document that Configure filename-based multi-targeting, such as including iOS files/folders as follows:
<ItemGroup Condition="$(TargetFramework.StartsWith('net8.0-ios')) != true">
...
<BundleResource Include="Resource\*.png" />
</ItemGroup>
However, there is an another way to include iOS files/folders as follows:
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0-ios'">
...
<MauiImage Include="Resource\*.png" />
</ItemGroup>
The effect of them is different, the first method will crash but the second will not.
I can not understand this. If someone has more information between using them, that will be much appreciated.
Oh, I have understanded that, the effect of them maybe the same at the most status.
But the code inside them should be the different, the fist condition != true
, then we should remove the include, such as follows:
<ItemGroup Condition="$(TargetFramework.StartsWith('net8.0-ios')) != true">
...
<BundleResource remove="Resource\*.png" />
</ItemGroup>
and the effect will be the same with second one.
Thanks for @FreakyAli taking care of this question.