A Windows-style graphic contrasts a successful package setup with a failed one caused by an unchecked option.
When you uninstall a modern Windows app packaged with MSIX, Windows normally plays the role of an obsessive neat freak: it deregisters the package for the user, sweeps away Start menu entries and app execution aliases, wipes virtualized I/O writes, and purges the app’s ApplicationData without looking back. Most of the time, that clean slate is exactly what makes MSIX preferable to legacy installers that leave registry crumbs and orphaned folders scattered across your drive. Yet anyone who builds, tests, or supports packaged Windows apps eventually runs into the opposite headache: needing to remove a package while keeping its saved state intact. On December 1, 2026, Microsoft Principal Software Engineer Howard Kapustein highlighted the PreserveApplicationData option on the Inside MSIX blog as the built-in lever for that exact scenario—though Microsoft’s own API and PowerShell documentation reveals a critical caveat that every developer and IT pro needs to know before relying on it.

If you only read the high-level pitch, PreserveApplicationData sounds like a universal safety switch for MSIX uninstalls. Dig into Microsoft Learn’s reference documentation, however, and a bright yellow caution sign lights up: PreserveApplicationData is restricted to packages deployed in development mode or registered from a loose file layout. Try invoking it on a standard production MSIX package installed from a .msix bundle or the Microsoft Store, and Windows won't quietly keep your user’s settings—it will reject the call outright. Understanding where PreserveApplicationData works, what it actually saves, and how it fits into the broader MSIX removal pipeline is the difference between a smooth dev loop and an unexpected E_INVALIDARG error.

A Windows-style graphic contrasts a successful package setup with a failed one caused by an unchecked option. What PreserveApplicationData Actually Saves—and What It Still Deletes​

To understand what PreserveApplicationData protects, it helps to draw a sharp line between an app’s formal state container and everything else Windows wires up during registration. As Kapustein explained in his Inside MSIX post, standard package removal for a user deletes Start menu entries, app execution aliases, virtualized I/O writes, and the package’s ApplicationData—specifically the state managed through the Windows ApplicationData APIs (Windows.Storage.ApplicationData) or the Windows App SDK Microsoft.Windows.Storage.ApplicationData APIs.

Setting PreserveApplicationData instructs the Windows deployment stack to deregister the package for the calling user while leaving that ApplicationData store behind. In the Windows App SDK’s Microsoft.Windows.Storage namespace, ApplicationData encompasses structured stores such as LocalFolder, LocalSettings, LocalCacheFolder, TemporaryFolder, SharedLocalFolder, and MachineFolder.

Crucially, however, Kapustein emphasizes that PreserveApplicationData is strictly surgical:

  • Preserved: App state stored through the Windows or Windows App SDK ApplicationData APIs.
  • Still deleted: Start menu entries, app execution aliases, virtualized I/O writes, and other package-associated artifacts. There is no equivalent flag to preserve those secondary integrations once the package registration is torn down.

In other words, if your application writes data outside the official ApplicationData APIs—relying instead on package-relative virtualized file or registry writes—PreserveApplicationData will not rescue it.

The Catch: Development Mode Only​

Before any IT administrator starts drafting migration scripts around PreserveApplicationData for enterprise fleet rollouts, there is a major boundary documented on Microsoft Learn that changes how this feature can be used in practice.

According to Microsoft Learn’s RemovalOptions enumeration documentation for Windows.Management.Deployment, PreserveApplicationData (enum value 4096) can only be applied to packages that were deployed with DeploymentOptions.DevelopmentMode. If you pass PreserveApplicationData when removing an incompatible package, PackageManager.RemovePackageAsync(String, RemovalOptions) fails and returns E_INVALIDARG.

Microsoft’s PowerShell documentation for Remove-AppxPackage echoes the exact same constraint: the -PreserveApplicationData switch is only applicable to apps under development that were registered from a file layout—commonly known as "loose file registered" packages. And while the Windows App SDK’s PackageDeploymentManager exposes RemovePackageOptions.PreserveApplicationData through a modern wrapper, Microsoft’s open-source Windows App SDK implementation maps that property directly down to the underlying Windows.Management.Deployment.RemovalOptions.PreserveApplicationData flag rather than inventing a new policy bypass.

That makes PreserveApplicationData a developer and QA workhorse—ideal when you are iterating on a manifest, unregistering an unpackaged-layout build from Visual Studio or PowerShell, and re-registering a fresh build without wiping test profiles—rather than a general-purpose backup mechanism for signed production MSIX packages.

Every API and PowerShell Route That Supports PreserveApplicationData​

Depending on whether you are automating removal inside a Windows App SDK desktop app, calling classic WinRT deployment APIs, or scripting from a terminal, Microsoft provides multiple entry points that accept the preservation flag.

1. Windows App SDK (PackageDeploymentManager)​

In the Microsoft.Windows.Management.Deployment namespace—supported across Windows App SDK 1.5, 1.6, 1.7, 1.8, and 2.0—the Inside MSIX guide demonstrates removing a package family for the calling user while keeping its ApplicationData by configuring RemovePackageOptions:

Code:
var packageDeploymentManager =
    new Microsoft.Windows.Management.Deployment.PackageDeploymentManager();

string packageFamilyName = "Contoso.Parts_1234567890abc";
var options = new Microsoft.Windows.Management.Deployment.RemovePackageOptions();
options.PreserveApplicationData = true;

var result = packageDeploymentManager
.RemovePackageAsync(packageFamilyName, options)
.GetAwaiter();

Microsoft Learn confirms that PackageDeploymentManager supports RemovePackageOptions.PreserveApplicationData across several removal methods:

  • RemovePackageAsync()
  • RemovePackageByFamilyNameAsync()
  • RemovePackageByFullNameAsync()
  • RemovePackageByUriAsync()
  • RemovePackageSetAsync()

Note that PackageDeploymentManager also provides a GetDefault() factory method in the Windows App SDK API surface, and RemovePackageOptions includes FailIfNotFound, PreserveRoamableApplicationData, and RemoveForAllUsers alongside PreserveApplicationData.

2. Windows Runtime (Windows.Management.Deployment.PackageManager)​

For direct WinRT calls without the Windows App SDK dependency, Windows.Management.Deployment.PackageManager offers two routes:

  • PackageManager.RemovePackageAsync(String, RemovalOptions) using RemovalOptions.PreserveApplicationData (4096), an enum introduced with Windows 10 build 10240. Microsoft Learn notes that this overload removes the package for the current user and also removes dependency packages for that user if no other installed packages depend on them.
  • PackageManager.RemovePackageByUriAsync(Uri, RemovePackageOptions) using the newer WinRT RemovePackageOptions class, which Microsoft Learn documents for Windows builds 26100 and 28000 alongside properties such as DeferRemovalWhenPackagesAreInUse, PreserveRoamableApplicationData, and RemoveForAllUsers.

3. PowerShell (Remove-AppxPackage)​

For quick command-line testing on a development machine, PowerShell’s Appx module exposes -PreserveApplicationData on Remove-AppxPackage. Building on the package-family filtering pattern shared in the Inside MSIX post, removing a package family for the current user while preserving its ApplicationData looks like this:

Code:
Get-AppxPackage Contoso.Parts `
  -PackageTypeFilter Main,Framework,Resource,Optional,Bundle |
  Remove-AppxPackage -PreserveApplicationData

Keep PowerShell’s parameter sets in mind before expanding that one-liner. Microsoft Learn places -PreserveApplicationData in RemoveByPackageSet, whereas -AllUsers (AllUsersSet), -User <SID> (UserSet), and -PreserveRoamableApplicationData (RemoveByPackageForRoamingSet) sit in separate, mutually exclusive parameter sets. You cannot tack -AllUsers or -User onto a -PreserveApplicationData command, and targeting another user profile in general requires administrator privileges and a user SID.

Comparing PreserveApplicationData and PreserveRoamableApplicationData​

It is easy to confuse PreserveApplicationData with its sibling option, PreserveRoamableApplicationData, especially since both sit side-by-side on RemovePackageOptions and Remove-AppxPackage. In practice, they solve two very different problems:

OptionEnum Value (WinRT)Scope & EligibilityWhat It PreservesKey Incompatibilities
PreserveApplicationData4096 (since Windows 10 build 10240)Current user; only packages deployed with DeploymentOptions.DevelopmentMode / loose file layoutAll ApplicationData for the packageIncompatible with PreserveRoamableApplicationData, -AllUsers, and -User parameter sets in PowerShell; returns E_INVALIDARG on non-dev packages
PreserveRoamableApplicationData128 (added in Windows 10 version 2004 / build 19041)Virtual desktop / remote server roaming scenariosOnly the roamable portion of the app’s dataExplicitly unsupported with PreserveApplicationData and RemoveForAllUsers

The takeaway is straightforward: PreserveRoamableApplicationData exists for virtual desktop infrastructure (VDI) scenarios where a user’s portable app state needs to follow them across remote session hosts without keeping the entire local cache, while PreserveApplicationData is tailored for keeping full local and settings state during development-mode removal cycles.

How Removal Fits Into the Broader MSIX Lifecycle​

Even when you leave PreserveApplicationData out of the picture, "Remove" in MSIX does not always behave like a traditional .msi uninstaller. As Microsoft Learn’s MSIX package lifetime documentation details, removing a package for a user first tears down that user’s registration and user-specific integrations, then checks whether any "strong references" still point to the staged payload.

Those strong references include another user’s registration, device-wide provisioning, static or persisted dynamic dependencies from other apps, or an active running process. If no strong references remain, Windows marks the package eligible for destaging and cleans up the payload from disk during deployment collection—which may happen asynchronously after the removal call returns. Conversely, if a process currently has the package in use, Windows normally requests an application shutdown unless you pass DeferRemovalWhenPackagesAreInUse (8192 in RemovalOptions), which lets the user keep working and defers cleanup until the app closes.

Practical Guidance Before You Run Removal Scripts​

If you are building or testing MSIX apps and want ApplicationData to survive a remove-and-reregister cycle, run through this quick checklist first:

  1. Verify deployment mode: Confirm the package was registered in DevelopmentMode (loose-file layout from Visual Studio or Add-AppxPackage -Register). If it was installed from a packaged .msix or .msixbundle without development mode, expect E_INVALIDARG.
  2. Audit where your app writes state: Anything saved via Windows.Storage.ApplicationData or Microsoft.Windows.Storage.ApplicationData stays intact; virtualized file/registry writes, Start menu tiles, and app execution aliases do not.
  3. Mind the user context: Remove-AppxPackage -PreserveApplicationData operates in the current user parameter set and cannot be combined with -AllUsers or -User.
  4. Use the right option for VDI: If you are managing non-persistent virtual desktops rather than local dev loops, evaluate PreserveRoamableApplicationData instead of PreserveApplicationData.

MSIX’s default cleanup philosophy is one of its biggest strengths on Windows 10 and Windows 11, keeping machines free of the digital clutter left by decades of legacy installers. With PreserveApplicationData—and a clear eye on its development-mode boundaries—developers get an escape hatch when they need test data to outlive a package registration, without sacrificing clean uninstalls for everyone else.

 

References

  1. PreserveApplicationData Inside MSIX 2026-12-01T17:00:40+00:00
  2. RemovalOptions Enum (Windows.Management.Deployment) - Windows apps | Microsoft Learn learn.microsoft.com
  3. PackageDeploymentManager Class (Microsoft.Windows.Management.Deployment) - Windows App SDK | Microsoft Learn learn.microsoft.com