Windows appx removal fails with x64 package full name, succeeds with neutral package full name

Jeff Price 0 Reputation points
2023-02-27T21:19:59.7866667+00:00

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!

Windows development | Windows App SDK
{count} votes

1 answer

Sort by: Most helpful
  1. Jeff Price 0 Reputation points
    2023-03-07T21:34:56.44+00:00

    I don't have a limited code sample that could easily demonstrate an issue.

    I was mostly hoping that there would be documentation on how this whole system works that I could read. I don't find the API documentation you linked to be particularly useful in this regard. The sample just demonstrates the basic behavior without any acknowledgement of the issues I think I'm seeing, and the API docs just use the same terms without defining them.

    That said, what we're doing now seems to work around the issue, and we've moved on to other problems. Thanks for your time.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.