Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xamarin.Android.Build.Tasks] Remove MAM targets from CoreResolve #7868

Merged
merged 2 commits into from
Mar 10, 2023

Conversation

jonpryor
Copy link
Member

@jonpryor jonpryor commented Mar 9, 2023

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. This will hopefully remove the circular dependency.

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.  This will hopefully remove the circular dependency.
Commit 78ef0ea 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*.
Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grabbed a .binlog from a random test on this PR:

image

I think the ordering changes here make sense, all the "remapping" targets now run in the same spot.

@jonpryor jonpryor merged commit 03fff8c into dotnet:main Mar 10, 2023
jonpryor added a commit that referenced this pull request Mar 10, 2023
)

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.
grendello added a commit to grendello/xamarin-android that referenced this pull request Mar 13, 2023
* main:
  [tests] `InstallAndroidDependenciesTest` uses `platform-tools` 34.0.1 (dotnet#7873)
  [ci] Parallelize and reduce overhead of MSBuild test stage. (dotnet#7850)
  [Xamarin.Android.Build.Tasks] Remove MAM targets from CoreResolve (dotnet#7868)
grendello added a commit to grendello/xamarin-android that referenced this pull request Mar 13, 2023
* main:
  [tests] `InstallAndroidDependenciesTest` uses `platform-tools` 34.0.1 (dotnet#7873)
  [ci] Parallelize and reduce overhead of MSBuild test stage. (dotnet#7850)
  [Xamarin.Android.Build.Tasks] Remove MAM targets from CoreResolve (dotnet#7868)
grendello added a commit to grendello/xamarin-android that referenced this pull request Mar 13, 2023
* main:
  [tests] `InstallAndroidDependenciesTest` uses `platform-tools` 34.0.1 (dotnet#7873)
  [ci] Parallelize and reduce overhead of MSBuild test stage. (dotnet#7850)
  [Xamarin.Android.Build.Tasks] Remove MAM targets from CoreResolve (dotnet#7868)
@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants