How to downgrade a provisioned package (with Add-AppxProvisionedPackage) using cmdline?

Kerenor 0 Reputation points
2023-09-05T07:48:17.5866667+00:00

In our enterprise environment, we provision a packaged uwp app (packed as MSIX) with the cmd

Add-AppxProvisionedPackage -Online -SkipLicense -PackagePath [path-to-package].msix

Because we want all the user accounts on a device to have the same applications installed.

This works fine when having to install a newer version of an msix, but not when having to install a prior version. Specifically the error in this case is:

Add-AppxProvisionedPackage : Cannot create a file when that file already exists.

It looks like we need to install using an appinstaller file that specifies <ForceUpdateFromAnyVersion>true</ForceUpdateFromAnyVersion> , but Add-AppxProvisionedPackage does not support installing using an appinstaller file.

I came across this question about Provisioning Support for Appinstaller, however the methods specified there don't work for this scenario

  • The first method - doing this:
Add-AppxProvisionedPackage -SkipLicense -Online -PackagePath .\FileName.msix
Add-AppxPackage -AppInstallerFile .\FileName.appinstaller​

fails installing the lower-version package with Add-AppxProvisionedPackage with the same error as described above, the "file already exists" error

  • The second method - doing this:
$AppInstallerLocation = "C:\Users\MSIX\Desktop\AppInstallers\HeadTraxPkg_x64.appinstaller" [xml]$AppInstallerContent = [xml]$(Get-Content $AppInstallerLocation)

## Installs the AppxPackage
Add-AppxPackage -AppInstallerFile $AppInstallerLocation

## Forces the App to be Provisioned
$PackageFamilyName = $(Get-AppxPackage -Name $($AppInstallerContent.AppInstaller.MainPackage.Name) -Publisher $($AppInstallerContent.AppInstaller.MainPackage.Publisher)).PackageFamilyName
$PackageManager = new-object windows.management.deployment.packagemanager

$PackageManager.ProvisionPackageForAllUsersAsync($PackageFamilyName)​
  • fails installing the lower-version package with Add-AppxPackage with the following error
Add-AppxPackage : Deployment failed with HRESULT: 0x80070005, Access is denied.

So my question is - how can I install a lower version of a provisioned msix package, without uninstalling the existing one, from command line?

Thanks!

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,065 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 43,941 Reputation points
    2023-09-06T08:49:03.4666667+00:00

    Hello there,

    Installation of earlier versions of an MSIX app package can be performed on a device without prior removal of the application. Triggering an installation of an earlier version of the same application will cause the client to review the app's manifest file contained within the installing MSIX app package. The review of the appxmanifest.xml file will identify delta differences between the currently installed app and the installer being executed on the device. This process maintains the data stored within the appdata folder. Any changes that were made when installing the upgraded version will not be undone if an earlier version of the MSIX app package is installed.

    https://learn.microsoft.com/en-us/windows/msix/desktop/managing-your-msix-deployment-downgrading

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer--