I am trying to convert a .NET Framework WPF app to .NET 5
I ran https://github.com/dotnet/try-convert, and removed some incompatible DLL refs.
Now, when I try to compile, I am presented with
NETSDK1135 SupportedOSPlatformVersion 10.0.19041.0 cannot be higher than TargetPlatformVersion 7.0
Any ideas as to what to look for? The project in question is a combination of .NET 5 and .NET Standard 2.1
This issue appeared on my end when adding Microsoft.Windows.SDK.Contracts to read the version applied during packaging using MSIX package.
I tried with @RolandJS solution, but still tons of errors.
Found: https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-enhance
It mentions that since .NET 5 (or a later release) and target Windows 10, version 1809 or a later, the Microsoft.Windows.SDK.Contracts is not needed anymore. Instead you should use the TargetFrameworkMoniker (TFM).
As mentioned by RolandJS already: In the project file change
<TargetFramework>net5.0-windows</TargetFramework>
to e.g.
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
Uninstall Microsoft.Windows.SDK.Contracts
I had the same error a few hours ago. I found this article useful: https://nicksnettravels.builttoroam.com/net-5-tfms/ As I understand the TargetFrameWork in the project file must include the same Windows version as the SDK Contract. My project file looks like this now:
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
<UseWPF>true</UseWPF>
...
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="1.1.0" />
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />
</ItemGroup>
...
Hope it is useful for you.
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