'How to fix TargetPlatformMinVersion problem in WPF app?

I'm trying to use Windows UI library in my WPF app, and whenever I install Microsoft.UI.Xaml I get the following error.

Microsoft.UI.Xaml nuget package requires TargetPlatformMinVersion >= 10.0.15063.0 (current project is -1)

How to resolve this issue?

My windows SDK version is the latest version downloaded from here.

My OS version is 20H2 and the build number is 19042.685

I tried changing the targeted framework from .NET Core 3, 3.1, and .NET 5.

[If you think the title of this question is not appropriate, feel free to suggest an edit.]



Solution 1:[1]

I had the same problem transferring my project from .NET Framework 4.8 to .NET 6 (needed to have "using declarations").

Here's how I fixed mine:

  1. Go to the affected project's settings.
  2. Go to General and Target OS version.
  3. Choose 1.0.19041.0 (or at the very least it must be 10.0.18362.0)
  4. In the Supported OS version, choose any version except 7.0 or 8.0.
  5. Build the project.

I think (I'm not sure) the issue here is UI.Xaml doesn't support Win 7 or Win 8.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 NoThrottle