Search code examples
c#.netmauimaui-blazor

How to resolve NET MAUI workload version mismatch?


I am new to .NET and I have been receiving this error:

"The current .NET MAUI package version '9.0.21' requires the .NET MAUI workload version to be at least '9.0.0'. The current .NET MAUI workload version is '8.0.83'."

I tried the things ChatGPT told me, I have also checked the dotnet version and it is "9.0.101". But the issue still persists and the app won't deploy.


Here's what I have tried: "1. Update the .NET MAUI Workload Run the following commands in your terminal or Developer Command Prompt for Visual Studio:

dotnet workload update

  1. Check Your .NET SDK Version Ensure you are using a compatible .NET SDK version for .NET MAUI. For .NET MAUI 9.x, you need .NET 8 SDK.

dotnet --version If it’s not .NET 8 (e.g., 8.0.x), download and install the latest .NET 8 SDK from the official .NET website.

  1. Update Visual Studio Ensure your Visual Studio is up-to-date:

Open Visual Studio.

  • Go to Help → Check for Updates.
  • Install the latest updates to ensure the correct workloads are supported.
  1. Clear and Restore NuGet Packages Sometimes stale packages can cause issues:
  • Delete the bin and obj folders in your project.

Restore packages:

dotnet restore

  1. Verify Workload Installation Check that the correct version of the .NET MAUI workload is installed:

dotnet workload list

Look for something like:

Copy code maui-windows 9.0.x maui-android 9.0.x maui-ios 9.0.x If the version is incorrect or missing, reinstall the workload:

dotnet workload install maui"


Solution

  • Possible cause: Using .net 8 (LTS) with maui 9.

    I was getting the mismatch error, 8.0.83

    "The current .NET MAUI package version '9.0.21' requires the .NET MAUI workload version to be at least '9.0.0'. The current .NET MAUI workload version is '8.0.83'."

    Even after updating the maui workload + and updating to the latest version of VS 2022.

    I didn't realize that maui9 required .net 9, and I have my target Frameworks still set to .net 8.

    <TargetFrameworks>net8.0-android</TargetFrameworks>
    

    updating it to

    <TargetFrameworks>net9.0-android</TargetFrameworks>
    

    Caused the build to work.