-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[net7.0] Make MAUI into a workload based on NuGet packs #14331
Conversation
### Description Backport of #11206 This change moves most - if not all - the logic, assemblies, build tasks, targets and props into NuGet packages. This allows .NET MAUI to be usable without having to care about what version of the workload is installed. There are still a few things - mostly the automagic and Windows fixes - in the workload pack, but this is probably temporary and/or non-essential for the working of the build. Things like the project capabilities are still in the workload as this is needed for the IDE and cannot be in NuGet packages. Everything else is now inside a NuGet package that can be upgraded, pinned and otherwise used without requiring VS to have installed the workload to match. There is the benefit of the NuGet packages being installed on disk and thus reducing/removing the need to download. But that is minimal now since we have smaller and fewer packages. # Conflicts: # eng/Versions.props # src/Controls/Foldable/src/Controls.Foldable.csproj # src/Controls/Maps/src/Controls.Maps.csproj # src/Controls/src/Core/Controls.Core.csproj # src/Controls/src/SourceGen/Controls.SourceGen.csproj # src/Controls/src/Xaml.Design/Controls.Xaml.Design.csproj # src/Core/maps/src/Maps.csproj # src/Maui.InTree.targets # src/Workload/Microsoft.Maui.Sdk/Sdk/BundledVersions.in.targets
Ultimately we want this to be an implicit reference which is not included by default and opt-in, however visual studio's Live Visual tree currently depends on the assembly existing and being loaded so we cannot yet remove it. The default property assignment can be removed once VS is ready for this.
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
This reverts commit 08ac322.
Build.Tasks and Resizetizer all build to the same location, so they need to match.
I have a test repo here with all the things just working using nugets: https://github.com/mattleibow/Microsoft.NET.Sdk.Maui/tree/nugets |
0a7acd6
to
22f4676
Compare
22f4676
to
261e104
Compare
/azp run MAUI |
No pipelines are associated with this pull request. |
Hello, @mattleibow We urgently need this solution that can use the specified Nuget version, but we have not understood the writing method of version 7.0. x. Can you provide a .csproj file so that we can understand how to set it up? For example, sample7.csproj. Thank you very much. This idea is very good. We use the version of the Main branch to compile the Nuget file and version 7.0.0-ci.net7.16393 under the dotnet7-feed folder. The error thrown: The content of the .csproj:
|
@mattleibow Would it be worth mentioning if this PR affects #12953 in any way? |
This PR is a backport of things in net8 and I mentioned in the other issue how you can actually disable all nugets and take control. Not sure if that helps? |
Hopefully, it does. I'll try. Thank you! |
Hello @mattleibow , I'm wondering, if Maui Essentials is now a NuGet pack?, so I can download the source code and contribute with it, if yes, where can I find it. Also to fix an issue I'm facing personally with the WebAuthenticator, since I need to overwrite it to fix an issue on Android devices using a different browser as default. Thanks in advance. |
The maui essentials will still be in this repo: https://github.com/dotnet/maui/tree/main/src/Essentials We are more just changing how you get this into the app. Previously it was via a workload magic, now you can technically update this separately via nuget or a PR build. |
Thanks @mattleibow for the response. That clarifies my question. |
One last question @mattleibow , is it possible to convert the WebUtils class to be public, so we can access the methods? Please. I am working/contributing on a fix for the WebAuthenticator from MAUI Essentials and when I try to overwrite some methods from the WebAuthenticator class I get an error saying that the WebUtils is not accesible due to its protection level. Thanks in advance. 🙂 |
Closing this as we will not be backporting this to net7.0. It is fairly risky - especially with the fact that we are doing this halfway through the net7 life. This is all merged and the only/default way in .net8. |
Description
Backport of:
This change moves most - if not all - the logic, assemblies, build tasks, targets and props into NuGet packages. This allows .NET MAUI to be usable without having to care about what version of the workload is installed.
There are still a few things - mostly the automagic and Windows fixes - in the workload pack, but this is probably temporary and/or non-essential for the working of the build. Things like the project capabilities are still in the workload as this is needed for the IDE and cannot be in NuGet packages.
Everything else is now inside a NuGet package that can be upgraded, pinned and otherwise used without requiring VS to have installed the workload to match. There is the benefit of the NuGet packages being installed on disk and thus reducing/removing the need to download. But that is minimal now since we have smaller and fewer packages.
Risks
Since we are doing a fairly major change very late into the .NET 7 release of MAUI, this PR could cause issues to appear that we do not know about. Users do many things in many different ways so we cannot foresee them all. This PR is ready to be merged but that is only because the issues I have thought of have been made known/fixed.
Since the current SR is going out soon, this will have to be in the next one. But maybe there is a way we can do a preview workload that allows for testing.
PR Testing
Since this is a PR that makes fundamental changes, it cannot be used via a simple
<MauiVersion>
property, however, it is quite easy:dotnet workload install maui --skip-sign-check --from-rollback-file https://aka.ms/maui-net7-nugets/rollback.json --source https://api.nuget.org/v3/index.json --source https://aka.ms/maui-net7-nugets/index.json
User Scenarios
With the PR for .NET 8, it was simple because
if net8 then nuget else workload
is the story, but this is doing a fairly major change to a released version and may have issues. To try and detect them, I will be testing:<MauiVersion>
to update to a newer version from NuGet?but we can maybe make dummy packages that do nothing and satisfy the restore.<MauiVersion>
to update to an older version from NuGet?Notes
Notes on Scenario 2
This scenario is a special case for the .NET 7 backport as it is not relevant for .NET 8 because .NET 8 never shipped with workloads. However, this logic is slightly different than before:
<MauiIgnoreWorkloadPackagingType>true</MauiIgnoreWorkloadPackagingType>
.$(MauiVersion)
and others are$(MauiWorkloadVersion)
and this is by design<MauiVersion>
only influenced the actual assemblies referenced.<MauiVersion>
is not 100% a great thing.Notes on Scenario 4
It would appear that multi-targeting net7;net8 is the same as multi-targeting net6;net7, however there is a significant difference:
BundledVersions.targets
. It just imports "dependency-only" packages:Microsoft.Maui.Extensions
,Microsoft.Maui.Dependencies
and thenMicrosoft.AspNetCore.Components.WebView.Maui
,Microsoft.Windows.SDK.BuildTools
.BundledVersions.targets
and as a result the .csproj directly imports a bunch of packages.Microsoft.Extensions.Logging.Debug
, the transitive dependencies of theMicrosoft.Maui.Extensions
package automatically upgrades and works seamlessly.Microsoft.AspNetCore.Components.WebView.Maui
package in a net6;net7 project, you have to condition this import to only import when the TFM is net7. The same will happen when adding .NET 8.Notes on Scenario 6
As mentioned in the "Reason", we can create a special SDK that can be referenced directly in the
<Project Sdk="Microsoft.NET.Sdk.Maui">
because everything is in a NuGet. The only code that is not in a NuGet is several<ProjectCapability>
items as well as some things for Windows - like setting up RID support and various other NuGet-restore-influencing properties.As of today, my testing has required the use of the
/<version>
in the Sdk, but I was also able to get this to work automatically using the MSBuild workload resolver if this SDK is registered as part of the workload manifest. This means that we could potentially have support for 2 ways of using .NET MAUI:<UseMaui>true</UseMaui>
<Project Sdk="Microsoft.NET.Sdk.Maui">
In both cases, the "default" version is set by the installed workload - but can be overridden by simply installing a newer NuGet package version in the csproj - no need for any workload updates.
See more at https://github.com/mattleibow/Microsoft.NET.Sdk.Maui/tree/nugets