You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Samples/MultiHeadedPackage/README.md
+18-9Lines changed: 18 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,16 +23,22 @@ These samples demonstrate how to create **multi-headed packages** — MSIX or sp
23
23
A WinUI 3 solution using single-project MSIX packaging with two projects:
24
24
25
25
-**PrimaryApp** — The main WinUI app that owns the package manifest. Uses `$targetnametoken$` tokens so the build system fills in the correct executable name.
26
-
-**SecondaryApp** — A secondary WinUI app referenced by PrimaryApp. Its executable name is hardcoded in the manifest as `SecondaryApp.exe` with `EntryPoint="Windows.FullTrustApplication"`.
26
+
-**SecondaryApp** — A console app included in the same MSIX package. Its executable name is hardcoded in the manifest as `SecondaryApp.exe` with `EntryPoint="Windows.FullTrustApplication"`.
27
27
28
28
After deployment, both apps appear in the Start menu as separate entries.
29
29
30
30
### Sparse sample (`cs/cs-wpf-sparse/`)
31
31
32
32
A WPF solution demonstrating multi-headed sparse packages with runtime registration:
33
33
34
-
-**PrimaryApp** — A WPF app with `WindowsPackageType=Sparse` that includes Register/Unregister/Restart buttons to manage the sparse package at runtime.
35
-
-**SecondaryApp** — A minimal WPF app that detects whether it has package identity (which it will once the sparse package is registered).
34
+
-**PrimaryApp** — A WPF app with `WindowsPackageType=Sparse` that registers the sparse package at runtime using the `PackageManager` API. After registration, it uses `IApplicationActivationManager` to relaunch with package identity via the app's AUMID (Application User Model ID).
35
+
-**SecondaryApp** — A minimal WPF app that detects whether it has package identity. Once the sparse package is registered, the primary app can launch this secondary app with identity using the `SecondaryApp` AUMID entry point.
36
+
37
+
Key implementation details:
38
+
- The manifest uses `uap10:AllowExternalContent="true"` to enable sparse packaging.
39
+
- Application entries use `uap10:RuntimeBehavior="win32App"` instead of `EntryPoint` (these are mutually exclusive).
40
+
- Restart/launch uses `IApplicationActivationManager.ActivateApplication()` with the package AUMID to ensure the process receives package identity. Launching the exe directly with `Process.Start` would bypass the package activation and the process would not have identity.
41
+
- A test certificate (`PrimaryApp_TemporaryKey.pfx`) is included because sparse packages must be signed to be registered.
36
42
37
43
## Prerequisites
38
44
@@ -52,14 +58,17 @@ A WPF solution demonstrating multi-headed sparse packages with runtime registrat
52
58
53
59
1. Open `cs/cs-wpf-sparse/MultiHeadedSparse.sln` in Visual Studio.
54
60
2. Set **PrimaryApp** as the startup project.
55
-
3. Press **Ctrl+F5** to run without debugging.
56
-
4. Click **Register Package** to register the sparse package.
57
-
5. Click **Restart** to relaunch with package identity.
58
-
6. Run **SecondaryApp** separately to verify it also detects the package identity.
61
+
3. Trust the test certificate: run `certutil -addstore TrustedPeople cs\cs-wpf-sparse\PrimaryApp\PrimaryApp_TemporaryKey.pfx` from an elevated terminal.
62
+
4. Press **Ctrl+F5** to build and run without debugging.
63
+
5. Click **Register Package** to register the sparse package with the OS.
64
+
6. Click **Restart** to relaunch the app with package identity (the status should now show the package full name).
65
+
7. Click **Launch Secondary App** to launch the secondary app entry point with package identity.
66
+
67
+
To clean up, click **Unregister Package** and restart.
-[Grant package identity by packaging with external location](https://docs.microsoft.com/windows/apps/desktop/modernize/grant-identity-to-nonpackaged-apps)
0 commit comments