Skip to content

Commit 20b53ac

Browse files
[.NET 6] fix for AndroidX.Migration (#184)
Context: dotnet/android#5195 Due to the way `<Import/>` ordering has changed with .NET 6 workloads, `$(AndroidApplication)` is not set until after NuGet packages have had their MSBuild targets evaluated. The result is `$(_AndroidXShouldRunMigration)` is blank, and AndroidX.Migration doesn't do any work. We noticed this happening in MSBuild tests using Xamarin.Forms.Maps. To solve this issue, we can check for `$(OutputType)` set to `Exe`, as this is what developers will set in their `.csproj` file. We may eventually get another MSBuild extension point from dotnet/sdk to make this possible to fix on the `xamarin-android`-side, but I think we can simply check both properties for now.
1 parent 07599f4 commit 20b53ac

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

source/migration/BuildTasks/Xamarin.AndroidX.Migration.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
<!-- "private" properties -->
3838
<PropertyGroup>
39-
<_AndroidXShouldRunMigration Condition="'$(_AndroidXShouldRunMigration)' == '' and '$(AndroidApplication)' == 'true' and '$(AndroidXIsUsingAndroidXLibraries)' == 'true' and '$(AndroidXSkipMigration)' != 'true'">true</_AndroidXShouldRunMigration>
39+
<_AndroidXShouldRunMigration Condition="'$(_AndroidXShouldRunMigration)' == '' and ('$(AndroidApplication)' == 'true' or '$(OutputType)' == 'Exe') and '$(AndroidXIsUsingAndroidXLibraries)' == 'true' and '$(AndroidXSkipMigration)' != 'true'">true</_AndroidXShouldRunMigration>
4040
<_AndroidXIntermediateOutputPath>$(IntermediateOutputPath)androidx\</_AndroidXIntermediateOutputPath>
4141
<_AndroidXProguardIntermediateOutputPath>$(_AndroidXIntermediateOutputPath)proguard\</_AndroidXProguardIntermediateOutputPath>
4242
<_AndroidXJavaLibraryIntermediateOutputPath>$(_AndroidXIntermediateOutputPath)jl\</_AndroidXJavaLibraryIntermediateOutputPath>

0 commit comments

Comments
 (0)