microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.85k stars 328 forks source link

Build error occurred when C# console app installed WinAppSDK 1.6 #4854

Open LegendaryBlair opened 3 weeks ago

LegendaryBlair commented 3 weeks ago

Describe the bug

I have a simple C# console app for .Net 6, installing Win app SDK 1.6 and then build is failing with the error message:

This version of the Windows App SDK requires Microsoft.Windows.SDK.NET.Ref  or later.
    Please update to .NET SDK 6.0.134, 6.0.426, 8.0.109, 8.0.305 or 8.0.402 (or later).
    Or add a temporary Microsoft.Windows.SDK.NET.Ref reference which can be added with:
        <PropertyGroup>
            <WindowsSdkPackageVersion></WindowsSdkPackageVersion>
        </PropertyGroup>
    Issue2338-4 F:\packages\NuGet\cache\microsoft.windowsappsdk\1.6.240923002\buildTransitive\Microsoft.WindowsAppSDK.targets   76  

Steps to reproduce the bug

  1. Create a simple C# console app for .NET 6
  2. Install Win app SDK 1.6 through .nuget package
  3. Build the project

Expected behavior

No build error.

Screenshots

Image

NuGet package version

Windows App SDK 1.6.1: 1.6.240923002

Packaging type

Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

The message is not actionable, I already installed .NET SDK 6.0.427, which is greater than .NET SDK 6.0.426 mentioned in the error message. NOTE: in the .NET download page https://dotnet.microsoft.com/en-us/download/dotnet/6.0, there's no .NET SDK 6.0.426.

dotnet --list-sdks 6.0.427 [C:\Program Files\dotnet\sdk] 8.0.403 [C:\Program Files\dotnet\sdk]

NOTE: Workaround exists. I need to manually update the csproj to the following to make it work. <TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>

manodasanW commented 3 weeks ago

Looks like we will need a check for when someone is not targeting the Windows OS version target framework which I assume was the case here.

dotMorten commented 2 weeks ago

This is documented in the release notes: https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/stable-channel#c-project-changes-1