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: doc/devdocs/modules/advancedpaste.md
+17-65Lines changed: 17 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,9 @@ See the `ExecutePasteFormatAsync(PasteFormat, PasteActionSource)` method in `Opt
33
33
34
34
## Debugging
35
35
36
-
Advanced Paste outputs to its own subfolder (`WinUI3Apps/AdvancedPaste/`) rather than the shared `WinUI3Apps/` folder. This isolates its `resources.pri` from other WinUI 3 apps due to a [known WinUI bug](https://github.com/microsoft/microsoft-ui-xaml/issues/10856).
36
+
Advanced Paste is packaged as a self-contained MSIX with its own identity (`Microsoft.PowerToys.AdvancedPaste`). This gives it native package identity for Windows AI APIs (Phi Silica) and clean `ms-appx:///` resource resolution without workarounds.
37
+
38
+
The MSIX is output to `WinUI3Apps/AdvancedPaste/` and registered by the module interface at runtime (or by the installer on release builds).
37
39
38
40
### Running and attaching the debugger
39
41
@@ -44,78 +46,32 @@ Advanced Paste outputs to its own subfolder (`WinUI3Apps/AdvancedPaste/`) rather
44
46
45
47
Alternatively, use the VS Code launch configuration **"Run AdvancedPaste"** from [.vscode/launch.json](/.vscode/launch.json) to launch the exe directly — but note that without the Runner, IPC and hotkeys won't work.
46
48
47
-
### Sparse package identity (local development)
48
-
49
-
Advanced Paste uses the Windows AI APIs (Phi Silica / `Microsoft.Windows.AI.Text.LanguageModel`) which require **package identity** at runtime. PowerToys provides this via a shared sparse MSIX package (`Microsoft.PowerToys.SparseApp`).
50
-
51
-
#### Why is this needed?
52
-
53
-
- The `LanguageModel` API requires a Limited Access Feature (LAF) unlock, which only succeeds when the calling process has a matching package identity.
54
-
- Advanced Paste is an unpackaged, self-contained WinUI 3 app. The sparse package grants it identity without converting it to a full MSIX.
55
-
- There is a [known WinUI bug](https://github.com/microsoft/microsoft-ui-xaml/issues/10856) where self-contained WinUI 3 apps with sparse identity only load `resources.pri` instead of module-specific PRI files. To avoid conflicts with other WinUI apps, Advanced Paste outputs to its own subfolder (`WinUI3Apps/AdvancedPaste/`) and uses `resources.pri` as its PRI filename.
56
-
57
-
#### One-time setup
58
-
59
-
1.**Build the sparse package** for your platform and configuration:
Advanced Paste uses the Windows AI APIs (Phi Silica / `Microsoft.Windows.AI.Text.LanguageModel`) which require **package identity** at runtime. The app is packaged as a self-contained MSIX (following the same pattern as Command Palette).
72
52
73
-
3.**Register the sparse package for development** by adding `-DevRegister` to the build command:
-**Build**: The csproj has `EnableMsixTooling=true` and `GenerateAppxPackageOnBuild=true` (CI builds). This produces an MSIX in `AppPackages/`.
56
+
-**Local dev**: VS registers the package automatically via `Add-AppxPackage -Register AppxManifest.xml` when you build.
57
+
-**Installer**: The WiX installer deploys the MSIX file and a custom action (`InstallAdvancedPastePackageCA`) registers it via `PackageManager`.
78
58
79
-
The `-DevRegister` flag automatically:
80
-
- Removes any existing registration
81
-
- Creates a temporary copy of `AppxManifest.xml` with the dev publisher
82
-
- Registers it via `Add-AppxPackage -Register` with `-ExternalLocation` pointing to your build output
83
-
- Verifies the result
59
+
#### Local development setup
84
60
85
-
You can combine it with the initial build (step 1) in a single command.
86
-
87
-
4.**Verify the registration:**
88
-
89
-
```powershell
90
-
$pkg = Get-AppxPackage -Name "*SparseApp*"
91
-
$pkg.Publisher # Should be: CN=PowerToys Dev, O=PowerToys, L=Redmond, S=Washington, C=US
92
-
$pkg.PublisherId # Should be: djwsxzxb4ksa8
93
-
$pkg.IsDevelopmentMode # Should be: True
94
-
```
95
-
96
-
#### Re-registration
97
-
98
-
Re-register after rebuilding the sparse package, changing `AppxManifest.xml`, or switching platforms/configurations:
61
+
For local debug builds, Visual Studio handles MSIX registration automatically. Select the **"PowerToys.AdvancedPaste (Package)"** launch profile in the debug dropdown.
|`Cannot locate resource from 'ms-appx:///Microsoft.UI.Xaml/Themes/themeresources.xaml'`| Sparse package not registered, or registered without `-ExternalLocation`| Re-register using step 3 above |
115
-
|`IsDevelopmentMode` is `False` after registration | Used `Add-AppxPackage -Path *.msix` instead of `-Register`| Remove and re-register using the `-Register` form |
116
-
| LAF unlock returns `Unavailable`| Publisher mismatch | Verify `$pkg.PublisherId` is `djwsxzxb4ksa8`|
117
-
|`HRESULT 0x800B0109` (trust failure) | Dev certificate not trusted | Run `Import-Certificate` (step 2) for both `TrustedPeople` and `TrustedRoot`|
118
-
119
75
### How Settings UI checks Phi Silica availability
120
76
121
77
Settings UI does not have MSIX package identity. To check whether Phi Silica is available, it queries the running Advanced Paste process via a named pipe (`powertoys_advancedpaste_phi_status`).
@@ -125,10 +81,6 @@ Advanced Paste checks LAF + `GetReadyState()` once on startup (with MSIX identit
125
81
-`NotReady` — model needs download via Windows Update
126
82
-`NotSupported` — not a Copilot+ PC, API unavailable, or Advanced Paste not running
127
83
128
-
### See also
129
-
130
-
-[microsoft/microsoft-ui-xaml#10856](https://github.com/microsoft/microsoft-ui-xaml/issues/10856) — the WinUI bug requiring separate output folder
0 commit comments