14

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?

2
  • Editing Project files is tricky and should be avoided. It is better to make changes inside VS. You need to select versions that are installed on the machine and VS will give list of installed versions. If version is missing than down load version outside VS and then select the version inside VS. If a library version is wrong delete the reference in Solution Explorer. Then add back the reference which will select the installed version on machine. See following for Core versions : dotnet.microsoft.com/en-us/download/dotnet/8.0 Commented Sep 13, 2024 at 8:47
  • I can't reproduce your problem. I installed the windows10.0.19041.41 and it's the default target windows framework. I can use the last version of Community Toolkit MVVM. Commented Sep 17, 2024 at 7:27

3 Answers 3

17

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

Sign up to request clarification or add additional context in comments.

1 Comment

After looking for a solution for a few hours, adding the <WindowsSdkPackageVersion>10.0.22621.41</WindowsSdkPackageVersion> to my project file solved the problem for me.
6

Same problem, tried everything (like you did) but can't get it working. Obviously some problem with the CommunityToolkit.Mvvm v8.3.1; I re-installed v8.2.2 and all works OK. Just need to wait until the update is fixed or more info available. hth.

2 Comments

Try this answer as well it might help: stackoverflow.com/a/78990501/2093880
That did it - thanks usefulBee :-)
1

I faced this issue as well and for my case this is how i fixed it

by navigating on the Error List tab>click on the error>Microsoft.WindowsAppSDK.targets window will open then paste the code

<PropertyGroup>
    <WindowsSdkPackageVersion>10.0.19041.38</WindowsSdkPackageVersion>
</PropertyGroup>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.