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

Support multiple runtime packs per FrameworkReference #24873

Closed
wants to merge 1 commit into from

Conversation

pjcollins
Copy link
Member

Fixes: #24077

The <ProcessFrameworkReferences/> task is already able to process a
@(KnownFrameworkReference) with multiple %(RuntimePackNamePatterns)
defined in a semi-colon delimited list. However, if multiple runtime
pack patterns are used the <ResolveFrameworkReferences/> will fail
soon after with the following error:

C:\Program Files\dotnet\sdk\6.0.300-preview.22173.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(326,5): error MSB4018: The "ResolveFrameworkReferences" task failed unexpectedly.
C:\Program Files\dotnet\sdk\6.0.300-preview.22173.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(326,5): error MSB4018: System.ArgumentException: An item with the same key has already been added. Key: Microsoft.Android

Fixes <ResolveFrameworkReferences/> to allow multiple runtime packs to
be associated with a single @(FrameworkReference). The following
@(ResolvedFrameworkReferences) metadata will now contain semi-colon
delimited lists of runtime pack information if multiple patterns are
provided:

%(ResolvedFrameworkReferences.RuntimePackPath) = path1;path2
%(ResolvedFrameworkReferences.RuntimePackName) = pack1;pack2.rid
%(ResolvedFrameworkReferences.RuntimePackVersion) = 7.0.0;7.0.0

The `<ProcessFrameworkReferences/>` task is already able to process a
`@(KnownFrameworkReference)` with multiple `%(RuntimePackNamePatterns)`
defined in a semi-colon delimited list.  However, if multiple runtime
pack patterns are used the `<ResolveFrameworkReferences/>` will fail
soon after with the following error:

    C:\Program Files\dotnet\sdk\6.0.300-preview.22173.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(326,5): error MSB4018: The "ResolveFrameworkReferences" task failed unexpectedly.
    C:\Program Files\dotnet\sdk\6.0.300-preview.22173.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(326,5): error MSB4018: System.ArgumentException: An item with the same key has already been added. Key: Microsoft.Android

Fixes `<ResolveFrameworkReferences/>` to allow multiple runtime packs to
be associated with a single `@(FrameworkReference)`.  The following
`@(ResolvedFrameworkReferences)` metadata will now contain semi-colon
delimited lists of runtime pack information if multiple patterns are
provided:

    %(ResolvedFrameworkReferences.RuntimePackPath) = path1;path2
    %(ResolvedFrameworkReferences.RuntimePackName) = pack1;pack2.rid
    %(ResolvedFrameworkReferences.RuntimePackVersion) = 7.0.0;7.0.0
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@pjcollins pjcollins requested a review from dsplaisted April 14, 2022 22:40
Copy link
Member

@dsplaisted dsplaisted left a comment

Choose a reason for hiding this comment

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

Do you only need this for 7.0? That's what main is targeting.

Were you able to test this end-to-end yet? It's OK if not, but I wonder if there are other parts of the code that will need to be updated to handle this.

Comment on lines +54 to +56
resolvedFrameworkReference.SetMetadata("RuntimePackPath", string.Join (";", matchingRuntimePacks.Select (mrp => mrp.GetMetadata(MetadataKeys.PackageDirectory))));
resolvedFrameworkReference.SetMetadata("RuntimePackName", string.Join (";", matchingRuntimePacks.Select (mrp => mrp.GetMetadata(MetadataKeys.NuGetPackageId))));
resolvedFrameworkReference.SetMetadata("RuntimePackVersion", string.Join (";", matchingRuntimePacks.Select (mrp => mrp.GetMetadata(MetadataKeys.NuGetPackageVersion))));
Copy link
Member

Choose a reason for hiding this comment

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

I don't see any changes in code that consumes these metadata values. Is that code going to be able to handle the multiple runtime packs?

Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't find any references in dotnet/sdk, aside from the tests that only make sure that this metadata is set. Maybe there are external usages that could break? Are you familiar with anything else that depends on these?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's used somewhere but I'm not sure. If it's really not used, then we don't even need to set the metadata at all (though it could be useful for debugging).

Copy link
Member Author

Choose a reason for hiding this comment

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

@dsplaisted are there any other folks we should loop in to determine whether we should remove this metadata or not? I'm not sure how to proceed.

@pjcollins
Copy link
Member Author

pjcollins commented Apr 18, 2022

As far as Android is concerned we would only want this for 7.0.100. This is working end to end for the couple of cases that I tested (single and multi rid build+run attempts on device). However, I only tested this patch after applying it to a .NET 6.0.300 SDK, as we aren't compatible with 7.0.100 previews yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question about supporting runtime packs for "parent" RIDs
2 participants