-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Workload dependencies should be able to flow through project and package dependencies. IE, if a project depends on a workload, projects which reference the project may need to also depend on that workload.
For iOS and Android workloads, the TargetFramework is what lights up the workload, so in that case the dependencies automatically depend on the same workload because they need to use a compatible TargetFramework. However, projects using .NET Maui can put shared logic in a project with a TargetFramework of net6.0, and set the UseMauiEssentials property to true to opt in to the Maui workload. We currently don't have a good way of flowing that workload dependency to other projects.
Some possible solutions:
Do nothing
Projects which consume NuGet packages which use NET Maui will have to explicitly set the UseMauiEssentials property. This is a poor experience, especially because there won't be anything to help developers know they need to do this.
Use FrameworkReference to drive explicit workload opt-in
Maui essentials does use a FrameworkReference to bring in the Maui library, and this will already flow through packages and (I think) project references. We could add logic to the SDK (possibly coming from workload manifests) that recognizes that this FrameworkReference comes from a workload, and generates an error about how to opt in to the workload.
Move KnownFrameworkReference for Maui essentials into .NET SDK
The KnownFrameworkReference for Maui essentials is in one of the Maui workloads. We could move it to the .NET SDK itself, so you don't need to use the workload in order to consume the FrameworkReference. However, this would make it harder to version consistently with the rest of the Maui workloads. Also, while it would work for Maui Essentials, which only adds some APIs, it would not work for a workload which needs to include build logic (such as Maui.Core, I think).
New NuGet feature to support flowing workloads
NuGet currently flows FrameworkReference items to consuming projects. However, we can't use MSBuild items to enable workloads, we need to use properties (this is due to the multi-pass way MSBuild evaluation works, where items aren't evaluated until all project imports have been resolved).
NuGet could be updated so that if a project depends on a workload, the information about what property needs to be set would be included in the NuGet package, and NuGet restore would set that property in the .nuget.g.props file it generates.
/cc @dotnet/dotnet-cli @Redth @jonathanpeppers @eerhardt @davidortinau @mhutch