-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
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
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. |
There was a problem hiding this 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.
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)))); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
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. |
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 failsoon after with the following error:
Fixes
<ResolveFrameworkReferences/>
to allow multiple runtime packs tobe associated with a single
@(FrameworkReference)
. The following@(ResolvedFrameworkReferences)
metadata will now contain semi-colondelimited lists of runtime pack information if multiple patterns are
provided: