[Xamarin.Android.Build.Tasks] fix for .NET 6 targeting pack locations #5767
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In .NET 6, we set a
$(_XATargetFrameworkDirectories)
MSBuildproperty to be used throughout the legacy MSBuild targets:
However, when testing a new workload for .NET Maui we hit the error:
The
net6.0
directory does not exist, because the assemblies are inplatform-specific directories such as
net6.0-android30.0
,net6.0-ios13.6
,net6.0-maccatalyst13.5
, etc.The problem with the current logic:
The
%(TargetFramework)
item metadata isnet6.0
, but we somehowneed to use the
net6.0-android30.0
directory.The
ResolvedTargetingPackAssets
MSBuild target from the dotnet/sdksets
@(Reference)
for each assembly that comes from a "targetingpack". The
@(Reference)
item group that contains item metadata suchas:
If we grab directories of each item with
%(FrameworkReferenceName)
filled out, which means they come from a "targeting pack":
Then as long as we use
->Distinct()
, we now get correct values for$(_XATargetFrameworkDirectories)
:After this change, I'm able to build projects with the .NET Maui
workload targeting Android. I think this logic should be correct going
forward in .NET 6.