Skip to content

Commit 34ad867

Browse files
[Xamarin.Android.Build.Tasks] add Condition in AutoImport.props (#9463)
One of the "gotchas" with `AutoImport.props`, is the file is imported by literally *all* .NET projects. Even .NET 8 and .NET 9 Android projects import their files on top of each other… This means every `<ItemGroup>` needs a `Condition` that checks: * Is this Android? * Is this the expected .NET framework version? `<ItemGroup>`s in `AutoImport.props` should have, something like: <ItemGroup Condition=" '$(TargetPlatformIdentifier)' == 'android' and $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '9.0')) "> `$(EnableDefaultAndroidItems)` checks also work for some cases, but [.NET MAUI turns this off in favor of their own wildcards][0]. [0]: https://github.com/dotnet/maui/blob/f269ef3de701043910c941bbbfcbdb7422cc245c/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.SingleProject.Before.targets#L10
1 parent fa7c367 commit 34ad867

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/Sdk/AutoImport.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ https://github.com/dotnet/designs/blob/4703666296f5e59964961464c25807c727282cae/
6262
<ProguardConfiguration Include="**\proguard-rules.pro" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
6363
</ItemGroup>
6464

65-
<ItemGroup>
65+
<ItemGroup Condition=" '$(TargetPlatformIdentifier)' == 'android' and $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '9.0')) ">
6666
<AndroidPackagingOptionsExclude Include="DebugProbesKt.bin" />
6767
<AndroidPackagingOptionsExclude Include="$([MSBuild]::Escape('*.kotlin*'))" />
6868
<AndroidPackagingOptionsInclude Include="$([MSBuild]::Escape('*.kotlin_builtins'))" />

0 commit comments

Comments
 (0)