dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.6k stars 1.04k forks source link

Is there a way to have multiple platforms in one runtime pack? #21578

Open jonathanpeppers opened 2 years ago

jonathanpeppers commented 2 years ago

Is your feature request related to a problem? Please describe.

Currently the maui workload has a lot of packs:

Microsoft.Maui.Core.Ref.any
Microsoft.Maui.Core.Runtime.any
Microsoft.Maui.Controls.Ref.any
Microsoft.Maui.Controls.Runtime.any
Microsoft.Maui.Essentials.Ref.any
Microsoft.Maui.Essentials.Runtime.any
Microsoft.Maui.Core.Ref.android
Microsoft.Maui.Core.Runtime.android
Microsoft.Maui.Controls.Ref.android
Microsoft.Maui.Controls.Runtime.android
Microsoft.Maui.Essentials.Ref.android
Microsoft.Maui.Essentials.Runtime.android
Microsoft.Maui.Core.Ref.ios
Microsoft.Maui.Core.Runtime.ios
Microsoft.Maui.Controls.Ref.ios
Microsoft.Maui.Controls.Runtime.ios
Microsoft.Maui.Essentials.Ref.ios
Microsoft.Maui.Essentials.Runtime.ios
Microsoft.Maui.Core.Ref.maccatalyst
Microsoft.Maui.Core.Runtime.maccatalyst
Microsoft.Maui.Controls.Ref.maccatalyst
Microsoft.Maui.Controls.Runtime.maccatalyst
Microsoft.Maui.Essentials.Ref.maccatalyst
Microsoft.Maui.Essentials.Runtime.maccatalyst
Microsoft.Maui.Core.Ref.win
Microsoft.Maui.Core.Runtime.win
Microsoft.Maui.Controls.Ref.win
Microsoft.Maui.Controls.Runtime.win
Microsoft.Maui.Essentials.Ref.win
Microsoft.Maui.Essentials.Runtime.win

All of these come via UseMaui=true, but you can select different sets of them with UseMauiEssentials=true or UseMauiCore=true.

What I would like to do, is collapse these into:

Microsoft.Maui.Core.Ref
Microsoft.Maui.Core.Runtime
Microsoft.Maui.Controls.Ref
Microsoft.Maui.Controls.Runtime
Microsoft.Maui.Essentials.Ref
Microsoft.Maui.Essentials.Runtime

And just put all the platforms in one pack for each. The packs are small in size, because they are mostly managed code.

I attempted this here: https://github.com/dotnet/maui/pull/2743

But what happens for the data/RuntimeList.xml file:

<FileList Name=".NET MAUI" TargetFrameworkIdentifier=".NETCoreApp" TargetFrameworkVersion="6.0" FrameworkName="Microsoft.Maui.Core">
  <File Type="Managed" Path="lib/net6.0/Microsoft.Maui.dll" AssemblyName="Microsoft.Maui" PublicKeyToken="" AssemblyVersion="1.0.0.0" FileVersion="6.0.101.8" />
  <File Type="Managed" Path="lib/net6.0-android31.0/Microsoft.Maui.dll" AssemblyName="Microsoft.Maui" PublicKeyToken="" AssemblyVersion="1.0.0.0" FileVersion="6.0.101.8" Profile="Android" />
  <File Type="Managed" Path="lib/net6.0-ios15.0/Microsoft.Maui.dll" AssemblyName="Microsoft.Maui" PublicKeyToken="" AssemblyVersion="1.0.0.0" FileVersion="6.0.101.8" Profile="iOS" />
  <File Type="Managed" Path="lib/net6.0-maccatalyst15.0/Microsoft.Maui.dll" AssemblyName="Microsoft.Maui" PublicKeyToken="" AssemblyVersion="1.0.0.0" FileVersion="6.0.101.8" Profile="MacCatalyst" />
  <File Type="Managed" Path="lib/net6.0-windows10.0.18362/Microsoft.Maui.dll" AssemblyName="Microsoft.Maui" PublicKeyToken="" AssemblyVersion="1.0.0.0" FileVersion="6.0.101.8" Profile="Windows" />
</FileList>

Is you end up with errors like:

D:\agent\1\s\bin\dotnet\sdk\6.0.100-rtm.21476.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(427,5): error NETSDK1110: More than one asset in the runtime pack has the same destination sub-path of 'Microsoft.Maui.dll'. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue. [D:\agent\1\s\src\Controls\samples\Controls.Sample.SingleProject\Maui.Controls.Sample.SingleProject.csproj]
D:\agent\1\s\bin\dotnet\sdk\6.0.100-rtm.21476.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(427,5): error NETSDK1110: More than one asset in the runtime pack has the same destination sub-path of 'Microsoft.Maui.dll'. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue. [D:\agent\1\s\src\Controls\samples\Controls.Sample.SingleProject\Maui.Controls.Sample.SingleProject.csproj]
D:\agent\1\s\bin\dotnet\sdk\6.0.100-rtm.21476.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(427,5): error NETSDK1110: More than one asset in the runtime pack has the same destination sub-path of 'Microsoft.Maui.dll'. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue. [D:\agent\1\s\src\Controls\samples\Controls.Sample.SingleProject\Maui.Controls.Sample.SingleProject.csproj]
D:\agent\1\s\bin\dotnet\sdk\6.0.100-rtm.21476.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(427,5): error NETSDK1110: More than one asset in the runtime pack has the same destination sub-path of 'Microsoft.Maui.dll'. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue. [D:\agent\1\s\src\Controls\samples\Controls.Sample.SingleProject\Maui.Controls.Sample.SingleProject.csproj]

So it just seems like alll assemblies are added.

Is there a way to put all the platforms in one pack?

Describe the solution you'd like

@Profile would be respected for Runtime packs? It's not clear to me if it's being respected for targeting/Ref packs, but those don't give an error.

If we could do this, it would eliminate 24 .msi's installed when running dotnet workload install maui in an Admin location. I think it might be a significant performance win, since msiexec can only install one at a time?

jonathanpeppers commented 2 years ago

/cc @dsplaisted @wli3

dsplaisted commented 2 years ago

I'd suggest solving this with #21741. We are already going to need to group multiple library packs into the same MSI, so I think we should support doing the same thing with other types of workload packs.

We can also add more flexibility to runtime packs if we need to, but if the only issue here is that it's a bunch of different MSIs, then I would just solve it by bundling the multiple packs into the same MSI.