Skip to content

Commit

Permalink
[Xamarin.Android.Build.Tasks] Remove MAM targets from CoreResolve (#7868
Browse files Browse the repository at this point in the history
)

Context: f6f11a5

We're working with the InTune team to make use of our member remapping
support (f6f11a5), and they hit a bit of a snag:

> I'm having some issues integrating it into the Xamarin build.
> We need our process to run after `_CompileJava` so we can analyze
> the inheritance of the app's classes. Now, we also need our process
> to run before `_CollectAndroidRemapMembers` so that the XML
> generated in that process can be consumed properly. Unfortunately,
> this generates a circular dependency:
>
>     error MSB4006: There is a circular dependency in the target dependency graph
>       involving target "_CollectAndroidRemapMembers".
>       Since "_ResolveLibraryProjectImports" has "DependsOn" dependence on
>       "_CollectAndroidRemapMembers", the circular is
>       "_CollectAndroidRemapMembers<-_ResolveLibraryProjectImports<-_ExtractLibraryProjectImports<-_GetLibraryImports<-_CompileJava<-…<-_CollectAndroidRemapMembers".

Commit f6f11a5 updated `$(CoreResolveReferencesDependsOn)` to add
the `_ConvertAndroidMamMappingFileToXml` and `_CollectAndroidRemapMembers`
targets, but @jonpryor does not remember *why* these targets needed
to be added to `$(CoreResolveReferencesDependsOn)` in the first place.

Update `$(CoreResolveReferencesDependsOn)` to remove the
`_ConvertAndroidMamMappingFileToXml` and `_CollectAndroidRemapMembers`
targets, and move those targets to the new
`$(_GenerateAndroidRemapNativeCodeDependsOn)` MSBuild property, which
is the `DependsOnTargets` list for the target
`_GenerateAndroidRemapNativeCode`.  This delays execution of the
`_ConvertAndroidMamMappingFileToXml` and `_CollectAndroidRemapMembers`
targets as late as possible, which should resolve the circular deps.
  • Loading branch information
jonpryor committed Mar 10, 2023
1 parent 75f1895 commit 58a54ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ projects, these properties are set in Xamarin.Android.Legacy.targets.
<CoreResolveReferencesDependsOn>
_SeparateAppExtensionReferences;
$(ResolveReferencesDependsOn);
_ConvertAndroidMamMappingFileToXml;
_CollectAndroidRemapMembers;
_AddAndroidCustomMetaData;
_ResolveAars;
</CoreResolveReferencesDependsOn>
Expand Down
10 changes: 9 additions & 1 deletion src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1645,8 +1645,16 @@ because xbuild doesn't support framework reference assemblies.
/>
</Target>

<PropertyGroup>
<_GenerateAndroidRemapNativeCodeDependsOn>
_ConvertAndroidMamMappingFileToXml;
_CollectAndroidRemapMembers;
_PrepareAndroidRemapNativeAssemblySources
</_GenerateAndroidRemapNativeCodeDependsOn>
</PropertyGroup>

<Target Name="_GenerateAndroidRemapNativeCode"
DependsOnTargets="_PrepareAndroidRemapNativeAssemblySources"
DependsOnTargets="$(_GenerateAndroidRemapNativeCodeDependsOn)"
Condition=" '@(_AndroidRemapMembers->Count())' != '0' "
Inputs="$(_XARemapMembersFilePath)"
Outputs="@(_AndroidRemapAssemblySource)">
Expand Down

0 comments on commit 58a54ae

Please sign in to comment.