Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft.Windows.SDK.NET.Ref error with Community Toolkit is not exists

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?

like image 605
Enrico Rossini Avatar asked Feb 05 '26 05:02

Enrico Rossini


1 Answers

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

like image 174
Michael Mairegger Avatar answered Feb 07 '26 21:02

Michael Mairegger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!