WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

SupportedOSPlatform is ignored by the installer

Open Joost-Jens-Luminis opened this issue 1 year ago • 7 comments

Describe the bug

We have upgraded our TargetFramework to net8.0-windows10.0.22621.0, but left the SupportedOSPlatform on 10.0.19041.0. However, doing this means the installer no longer allows us to install our windows APP on any Windows version older then 22621.

Is this intentional? If so, what is the point of SupportedOSPlatform?

Steps to reproduce the bug

Set your settings as follows: image

Expected behavior

We are able to install on Windows version 14091.

Screenshots

The installer returns the following reason for installation failure: App installation failed with error message: Windows cannot install package because this package is not compatible with the device. The package requires OS version 10.0.22621.0 or higher on the Windows.Desktop device family. The device is currently running OS version 10.0.19041.208. (0x80073cfd)

NuGet package version

Windows App SDK 1.5.6: 1.5.240802000

Packaging type

Packaged (MSIX)

Windows version

Windows 10 version 2004 (19041, May 2020 Update)

IDE

Visual Studio 2022

Additional context

We have to upgrade the TFM due to the CommunityToolkit requiring this for an upcoming version. But I have tested this behavior without those new packages (so only the above mentioned change) and this error still happens.

Joost-Jens-Luminis avatar Aug 20 '24 06:08 Joost-Jens-Luminis

We are creating the installer as follows:

  • task: CmdLine@2 displayName: Bundle msix files to msixbundle continueOnError: true inputs: script: | "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\makeappx.exe" bundle /d $(Build.ArtifactStagingDirectory)\ /p "$(Build.ArtifactStagingDirectory)$(applicationName).msixbundle"

Joost-Jens-Luminis avatar Aug 21 '24 06:08 Joost-Jens-Luminis

I have found the solution. The Windows Project files requires <TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>

The AppXManifest.xml file gets the MinVersion from this property. But with a WinUI app this property is not usually present in the .csproj file. Instead, it has the SupportedOSPlatformVersion property, however, this is not used for the AppXManifest.xml file and thus not used for the manifest of the Bundle.

Joost-Jens-Luminis avatar Aug 21 '24 09:08 Joost-Jens-Luminis

I think SupportedOSPlatform is not part of WinAppSDK templates and is not used at all by WinAppSDK. TargetPlatformMinVersion is in the template and there is also a MinVersion specified on TargetDeviceFamily in the Package.appxmanifest, which I believe is what the installer checks. We should see if everything here makes sense.

codendone avatar Aug 22 '24 16:08 codendone

That is what we thought as well. But that is not what we are seeing. TargetPlatformMinVersion is what is determining the value that gets places in AppxManifest.xml by the compiler. The value in AppxManifest.xml is what is determining what gets used by MakeApp.exe and put in the msixbundle in the <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.19041.0" MaxVersionTested="10.0.19041.0"/>

Joost-Jens-Luminis avatar Aug 23 '24 06:08 Joost-Jens-Luminis

MaxVersionTested="10.0.19041.0"

P.S. That means you're telling Windows "I don't understand anything newer than 10.0.19041.0. Hide any such behaviors from me." That'll prevent you from using features in appxmanifest.xml newer than 10.0.19041.0.

<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.19041.0" MaxVersionTested="10.0.22621.0"/> means to install you require >=10.0.19041.0 but understand how to run on that and newer systems <= 10.0.22621.0 so 'light up' behavior >=10.0.19041.0 on newer systems.

DrusTheAxe avatar Oct 04 '24 08:10 DrusTheAxe

@DrusTheAxe Well, that is what is placed there by the compiler it seems, we are not setting this there directly.

Joost-Jens-Luminis avatar Oct 04 '24 09:10 Joost-Jens-Luminis

@DrusTheAxe Well, that is what is placed there by the compiler it seems, we are not setting this there directly.

It'll be set by VS, or some .props/targets/tasks provided by VS or friends as part of the package.appxmanifest-to-appxmanifest.xml transformation VS projects do as part of their build process.

@Scottj1s this is more up your alley than mine. Got any advice on this one?

DrusTheAxe avatar Oct 18 '24 05:10 DrusTheAxe