From 78ef0eaf09dd8842e22ad18d74733495be96778e Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 9 Mar 2023 12:10:39 -0500 Subject: [PATCH 1/2] [Xamarin.Android.Build.Tasks] Remove MAM targets from CoreResolve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Context: f6f11a5a797cd8602854942dccb0f2b1db57c473 We're working with the InTune team to make use of our member remapping support (f6f11a5a7), 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 f6f11a5a7 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. This will hopefully remove the circular dependency. --- .../targets/Microsoft.Android.Sdk.BuildOrder.targets | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.BuildOrder.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.BuildOrder.targets index fa15917a912..59836b76789 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.BuildOrder.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.BuildOrder.targets @@ -110,8 +110,6 @@ projects, these properties are set in Xamarin.Android.Legacy.targets. _CreatePropertiesCache; _SeparateAppExtensionReferences; $(ResolveReferencesDependsOn); - _ConvertAndroidMamMappingFileToXml; - _CollectAndroidRemapMembers; _AddAndroidCustomMetaData; _ResolveAars; From 584afbcd599ca44efd96b7fe4e1ebc8f28a0e0b4 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 9 Mar 2023 20:45:49 -0500 Subject: [PATCH 2/2] Fix unit test build failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 78ef0eaf didn't work; various unit tests failed with: error XAGJRNC7023: System.IO.DirectoryNotFoundException: Could not find a part of the path '…/tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/xa-internal/xa-remap-members.xml'. Meaning explicitly mentioning the `_ConvertAndroidMamMappingFileToXml` and `_CollectAndroidRemapMembers` targets was important! A (slightly!) more in depth investigation suggests that the only target that depends on the outputs of these targets is the `_GenerateAndroidRemapNativeCode` target. On the hope that this is in fact the case, add a new `$(_GenerateAndroidRemapNativeCodeDependsOn)` MSbuild property which is the target dependencies of the `_GenerateAndroidRemapNativeCode` target, and add `_ConvertAndroidMamMappingFileToXml` and `_CollectAndroidRemapMembers` to `$(_GenerateAndroidRemapNativeCodeDependsOn)`. This *should* ensure that the targets are executed *as late as possible*. --- .../Xamarin.Android.Common.targets | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index 2093580d04d..16f631f0d21 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -1706,8 +1706,16 @@ because xbuild doesn't support framework reference assemblies. /> + + <_GenerateAndroidRemapNativeCodeDependsOn> + _ConvertAndroidMamMappingFileToXml; + _CollectAndroidRemapMembers; + _PrepareAndroidRemapNativeAssemblySources + + +