tldr: How am I supposed to use RemovePackageAsync?
I've got a packages Windows app that I install using StagePackageAsync followed by ProvisionPackageForAllUsersAsync. The package is specifically x64 only. When I install, I do have the package installed under two architectures: x64
and neutral
.
When I use FindPackages to examine the system, I only see the x64
architecture. When I look at volumes and then use FindPackages on the volume I see both the x64
and neutral
architectures, with unique install paths. e.g. full names
myAppName_1.2.3.4_x64__someId
myAppName_1.2.3.4_neutral_~_someId
When I uninstall the app I call RemovePackageAsync. I get different result from RemovePackageAsync
depending on whether I call it with the full name for the x64
architecture or the neutral
architecture.
When I use the x64
full name I sometimes get the following error. This doesn't occur on all systems, but on systems where it does occur it appears to happen every time.
Deployment DeStage operation with target volume C: on Package myAppName_1.2.3.4_x64__someId from: failed with error 0x80070002. See http://go.microsoft.com/fwlink/?LinkId=235160 for help diagnosing app deployment issues.
Going to that link showed me where to look in the event viewer to find:
Opening registry key: Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications\myAppName_1.2.3.4_x64__someId failed with error: 0x80070002.
Looking for that registry key on systems where this is installed doesn't show it. Even on the system where this works I never have that key. I do have the equivalent key for the neutral
architecture on all systems
Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications\myAppName_1.2.3.4_neutral__someId
Using all this knowledge, I've been able to work around my uninstall problem by just trying both full names, and ignoring any errors. I "prove" it's really uninstalled by doing another check after trying and seeing if I can find any such packages. If I get 0 packages after uninstall I call that a success.
I'm looking for an explanation of this behavior, and best practices around removing packages using this API. Thanks!