Shared Package Container and AppModel API


The PSF uses the AppModel API (appmodel.h and kernel.appcore.dll) to obtain information about the currently executing package it is in.


In a scenario with SPC, there are multiple packages, and these calls can only learn about one of the packages (making certain types of fixes impossible). 


Is there an API to find the  the other packages running in the container such that AppModel calls can be made against those packages?

5 Replies

@TIMOTHY MANGAN There is an API for that yes SharedPackageContainerManager Class (Windows.Management.Deployment) - Windows UWP applications | Mic...


One of our engineers has shared a snipped of code that might help get you started

            auto id = CreatSimpleContainer(L"container", {

            auto manager = winrt::SharedPackageContainerManager::GetDefault();
            // Get container
            auto container = manager.GetContainer(id);

            log(L"Container name: ", container.Name().c_str());
            log(L"Container id: ", container.Id().c_str());
            VERIFY_ARE_EQUAL(container.Name(),                      L"container");
            VERIFY_ARE_EQUAL(container.Id().size(),                 36u);

            auto members = container.GetMembers();
            VERIFY_ARE_EQUAL(members.Size(), 2u);
            VERIFY_ARE_EQUAL(members.GetAt(0).PackageFamilyName(),  L"family1_8wekyb3d8bbwe");
            VERIFY_ARE_EQUAL(members.GetAt(1).PackageFamilyName(),  L"family2_8wekyb3d8bbwe");


@Aditi_Narvekar Thank you.  I was hoping to access the API from C++ (to be added as part of the Package Support Framework, which currently doesn't support Shared Package Groups when software in multiple packages needs the PSF in an MSIX package).  Is there any chance of a non-UWP API out there?





To provide priority context, this isn't something needed right away. But whenever Office (or parts of Office) move to the container, and a substantial number of Enterprises have finished hardware refreshes and move to Windows 11), then we'll really need it.

@TIMOTHY MANGAN So a couple of things:

  1. this code can be run outside of any package or container.
  2. it is non-UWP C++ code calling into the cppwinrt API.  this code can be called in a "simple" win32 C++ program that consumes cppwinrt.
  3. this cppwinrt API surface is for querying and modifying the SPC definition, but, it does not provide "live" diagnostics of the container (e.g. it does not tell you which packages are actually currently in the SPC)


OK. Great! Guess I have some research to do on how I do this (I should have said non-managed C++ but hopefully not important).