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.79k stars 319 forks source link

1.1 preview 1 breaks NET5.0 and 6.0 projects. #2338

Open dhoehna opened 2 years ago

dhoehna commented 2 years ago

Describe the bug

Adding Windows App SDK 1.1-Preview 1 to a .NET projects causes the project build to fail, saying that "Target Framework is empty". Specifically: A numeric comparison was attempted on "$(TargetPlatformVersion)" that evaluates to "" instead of a number, in condition "'$(TargetPlatformVersion)' < '10.0.18362.0'". C:\Users\dahoehna.nuget\packages\microsoft.windowsappsdk\1.1.0-preview1\buildTransitive\Microsoft.InteractiveExperiences.Common.targets

Steps to reproduce the bug

  1. Make a new C# project targeting either 5.0 or 6.0.
  2. Install the nuget package for Windows App SDK 1.1-Preview 1.

Expected behavior

A message in the build output asking to add the windows version to the "TargetFramework" attribute in the csproj.

Screenshots

No response

NuGet package version

No response

Packaging type

Unpackaged

Windows version

No response

IDE

Visual Studio 2022

Additional context

There is currently a workaround by adding the version manually.

Change net6.0 to net6.0-windows10.0.19041.0

riverar commented 2 years ago

Yup, I run into this brick wall a lot, to the point where I learned to check TFM when strange things start happening. When this occurs you typically lose access to the project file editing experience too, making it very difficult to quickly fix. Generally Visual Studio requires a restart once in this state.

jeromelaban commented 1 year ago

This issue is still very much present, but can be aggravated in cross-targeted projects by the NuGet package manager not supporting conditional ItemGroups properly: https://developercommunity.visualstudio.com/t/NuGet-Package-manager-does-not-honor-con/10269291

MSLukeWest commented 10 months ago

@manodasanW There's been another instance of this, see https://developercommunity.visualstudio.com/t/installing-WindowsAppSDK-can-lead-to-pro/10429073

Can the targets be updated to avoid this comparison when TargetPlatformVersion isn't set?

axtens commented 2 months ago

This is still an issue when converting from net7.0 to net8.0 in Uno projects, viz

A numeric comparison was attempted on "$(TargetPlatformVersion)" that evaluates to "" instead of a number, in condition "'$(TargetPlatformIdentifier)' == 'Windows' and
 '$(TargetPlatformVersion)' >= '8.0'".  C:\Users\Daisy\.nuget\packages\microsoft.windowsappsdk\1.5.240607001\buildTransitive\Microsoft.UI.Xaml.Markup.Compiler.interop.targets
ramiz272 commented 2 months ago

replace this line in file : C:\Users\dahoehna.nuget\packages\microsoft.windowsappsdk\1.1.0-preview1\buildTransitive\Microsoft.InteractiveExperiences.Common.targets

Line to replace: <Ixp-UAPTargetVersion Condition="'$(TargetPlatformVersion)' &lt; '10.0.18362.0'">uap10.0.17763</Ixp-UAPTargetVersion> TO: <Ixp-UAPTargetVersion Condition=" '$(TargetPlatformVersion)' != '' And '$(TargetPlatformVersion)' &lt; '10.0.18362.0'">uap10.0.17763</Ixp-UAPTargetVersion>

WILL RESOLVE THIS ISSUE :)

ramiz272 commented 2 months ago

This is still an issue when converting from net7.0 to net8.0 in Uno projects, viz

A numeric comparison was attempted on "$(TargetPlatformVersion)" that evaluates to "" instead of a number, in condition "'$(TargetPlatformIdentifier)' == 'Windows' and
 '$(TargetPlatformVersion)' >= '8.0'".  C:\Users\Daisy\.nuget\packages\microsoft.windowsappsdk\1.5.240607001\buildTransitive\Microsoft.UI.Xaml.Markup.Compiler.interop.targets

replace this line in file : C:\Users\Daisy.nuget\packages\microsoft.windowsappsdk\1.5.240607001\buildTransitive\Microsoft.UI.Xaml.Markup.Compiler.interop.targets

Line to replace: <Ixp-UAPTargetVersion Condition="'$(TargetPlatformVersion)' &lt; '10.0.18362.0'">uap10.0.17763</Ixp-UAPTargetVersion> TO: <Ixp-UAPTargetVersion Condition=" '$(TargetPlatformVersion)' != '' And '$(TargetPlatformVersion)' &lt; '10.0.18362.0'">uap10.0.17763</Ixp-UAPTargetVersion>

WILL RESOLVE THIS ISSUE :)