Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NETSDK1135 SupportedOSPlatformVersion 10.0.19041.0 cannot be higher than TargetPlatformVersion 7.0

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

enter image description here

Any ideas as to what to look for? The project in question is a combination of .NET 5 and .NET Standard 2.1

like image 584
Julien Avatar asked Nov 26 '20 20:11

Julien


2 Answers

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

like image 114
Rumble Avatar answered Nov 15 '22 13:11

Rumble


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.

like image 33
RolandJS Avatar answered Nov 15 '22 12:11

RolandJS