Search code examples
c#.netwpf.net-core.net-4.8

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


Solution

  • 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.