I have just updated my .NET 8 MAUI application and in particular the Community Toolkit MVVM. The application works for iOS and Android. When I try to start the Windows version, I get this error
MVVMTKCFG0003 This version of the MVVM Toolkit requires 'Microsoft.Windows.SDK.NET.Ref' version '10.0.19041.38' or later. Please update to .NET SDK 8.0.109, 8.0.305 or 8.0.402 (or later). Alternatively, use a temporary 'Microsoft.Windows.SDK.NET.Ref' reference, which can be done by setting the 'WindowsSdkPackageVersion' property in your .csproj file. For your project configuration, it is recommended to set the package version to '10.0.19041.41'. LanguageInUse (net8.0-windows10.0.19041.0) C:\Users\enric.nuget\packages\communitytoolkit.mvvm\8.3.1\buildTransitive\CommunityToolkit.Mvvm.WindowsSdk.targets
So, I edited the project and changed this line
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">
$(TargetFrameworks);net8.0-windows10.0.19041.0
</TargetFrameworks>
in
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">
$(TargetFrameworks);net8.0-windows10.0.19041.41
</TargetFrameworks>
Also, I updated the .NET SDK, downloading the latest version. After that, I get another error because this version is not recognized. How can I fix it?
Adding the following line to the project file or Directory.Build.props should do the trick.
<PropertyGroup>
<WindowsSdkPackageVersion>10.0.19041.41</WindowsSdkPackageVersion>
</PropertyGroup>
I saw that the default referenced Microsoft.Windows.SDK.NET.Ref is 10.0.19041.34 which is to lower than the minimum required as specified in the following code: https://github.com/CommunityToolkit/dotnet/blob/main/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.WindowsSdk.targets#L30
Follow up: https://github.com/CommunityToolkit/dotnet/issues/951
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With