NETSDK1135 SupportedOSPlatformVersion 10.0.19041.0 cannot be higher than TargetPlatformVersion 7.0
Asked Answered
F

3

23

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

Foredo answered 26/11, 2020 at 20:0 Comment(0)
H
20

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.

Halfbreed answered 27/11, 2020 at 23:27 Comment(0)
H
18

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

Hydroscope answered 16/12, 2021 at 14:0 Comment(2)
this was what i needed! thank youHopscotch
I wish I could upvote this 15 times. This should be the answer!!Kure
N
0

In my scenario I had by mistake 2 TargetFrameworks with windows keyword defined in my .csproj:

    <TargetFrameworks>net8.0-android;net8.0-ios;net8.0-windows</TargetFrameworks>
    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.18362.0</TargetFrameworks>

So had to remove the net8.0-windows from the first line

Nottingham answered 1/8, 2024 at 10:52 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.