-
Notifications
You must be signed in to change notification settings - Fork 401
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
[Housekeeping] Add MSBuild Task to Verify .NET MAUI Workload Installed on Local Machine #2266
base: main
Are you sure you want to change the base?
Conversation
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 really like this idea and can see value on it. I added some comments around the current implementation and I want to add.
I tried on my end and inspect the nuget, and right now the target isn't packaged correctly, I did some changes locally and could make it pack as expected for the BuildTasks.csproj
but couldn't if we want this targets to be built with Core
project.
I suggest that we ship it as a separated nuget package and add a reference to that package in our core project.
After appling that on my end I could see it during the build phase
src/CommunityToolkit.Maui.BuildTasks/CommunityToolkit.Maui.BuildTasks.csproj
Outdated
Show resolved
Hide resolved
@@ -44,6 +44,12 @@ | |||
<Configurations>Debug;Release</Configurations> | |||
</PropertyGroup> | |||
|
|||
<UsingTask TaskName="VerifyMauiWorkloadVersionTask" AssemblyFile="..\CommunityToolkit.Maui.BuildTasks\bin\$(Configuration)\$(NetVersion)\CommunityToolkit.Maui.BuildTasks.dll" /> |
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 believe this will not work the way you expect...
If I understood correctly you want to run the MSBuild task when the users build the project. The way it's coded here, this will run during the build of Core
project and not on the MauiApp project.
If you want it to run on the way that I mentioned, in the app project, this should be moved to a target file inside the BuildTasks
folder and pack from there
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(NetVersion)</TargetFramework> |
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'm not sure if you want to use the net8
here... It's recommended to use netstandard
for MsBuild tasks, because the project may run on IDEs and/or tools that doesn't support net8
. For example, Visual Studio runs on top of .net framework, and using net 8
may cause errors
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
<UsingTask TaskName="VerifyMauiWorkloadVersionTask" AssemblyFile="..\CommunityToolkit.Maui.BuildTasks\bin\$(Configuration)\$(NetVersion)\CommunityToolkit.Maui.BuildTasks.dll" /> | ||
|
||
<Target Name="VerifyMauiWorkloadVersionTask" BeforeTargets="Build"> | ||
<VerifyMauiWorkloadVersionTask MinimumRequiredMauiVersion="$(RequiredMauiWorkloadVersion)" /> |
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.
The property defined above is named _RequiredMauiWorkloadVersion
, with underscore.
@filipnavara by any chance, do you know how we can add the
|
While I appreciate the intention there seems to be a misunderstanding about how the whole SDK and workload versioning works. It's an officially supported scenario to use .NET SDK version X to build apps targeting .NET <= X. The workloads are bound to the SDK that is used for the build, not the TFM that the application targets. .NET 9 workloads can build both
If you really want a reliable check you should be shipping MSBuild script inside the NuGet that verifies on the actual build that OS-specific assets were picked by NuGet... |
Furthermore, there are two distinct workload update modes, configurable with For example, this is the output I get with 8.0.402 SDK with the
This is .NET 9 RC1 SDK with the
|
Description of Change
This PR creates a new project,
CommunityToolkit.Maui.BuildTasks
, where we can create MSBuild Tasks to run verification steps after developers have installed our NuGet Package.In
CommunityToolkit.Maui.BuildTasks
, I've createdCommunityToolkit.Maui.BuildTasks
that verifies the user has the minimum required version of .NET MAUI installed on their local machine.To Do
PR Checklist
main
at time of PRAdditional information
This PR is a work-around until Microsoft improves the .NET Workload tooling. Currently, there is no way for us to require a minimum .NET Workload version before a user installs our app.
Each time we bump our minimum required version of .NET, we subsequently bump our minimum required version of .NET MAUI. However, there are no tools in the chain to notify the user they must update their .NET MAUI Workload, leading to users opening many Issues on our repo where we repeat our recommendations for them to update the .NET SDK and update the .NET MAUI workload.
This PR should help us avoid users opening these "Issues".