Skip to content

Fix installed-build launch crash (resources.pri) and dead tray menu items#58

Merged
StuartMeeks merged 2 commits into
mainfrom
fix/publish-missing-resources-pri
Jun 8, 2026
Merged

Fix installed-build launch crash (resources.pri) and dead tray menu items#58
StuartMeeks merged 2 commits into
mainfrom
fix/publish-missing-resources-pri

Conversation

@StuartMeeks

@StuartMeeks StuartMeeks commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Two fixes for the installed (Velopack) build. Both verified on the Win11 build host with the exact CI release config (dotnet publish -c Release -r win-x64 --self-contained true, R2R on); a raw published exe was launched interactively (the launch crash isn't reproducible from a VS Debug run).

1. Installed builds crashed on launch — missing resources.pri

Installed builds crashed on launch on multiple machines with a blank window; the crash log showed a XamlParseException at ShellPage..ctorLoadComponent with no inner exception. VS Debug was unaffected.

Root cause: the self-contained Release publish shipped no app resources.pri — only the WindowsAppSDK framework PRIs. With the app's resource index absent, ms-appx:/// lookups for the app's own XAML failed. App.xaml limped through on the framework PRIs (so the app reached OnLaunched); the first app-specific page (ShellPage) died.

Enriching CrashLog to dump HRESULT + Exception.Data surfaced the real error (not in Message):

HRESULT: 0x802B000A
Data[RestrictedDescription]: Cannot locate resource from 'ms-appx:///Views/ShellPage.xaml'.

Two compounding defects:

  1. Publish never copied the app PRI — generated into bin but dropped by dotnet publish, because the WinUI PRI/packaging targets weren't imported. EnableMsixTooling=true (required for unpackaged self-contained WinUI per the Windows App SDK docs) wires in the copy-to-publish step.
  2. Wrong PRI name — an unpackaged app auto-loads only resources.pri from the exe dir, but the build names it after the assembly (Snipdeck.App.pri), which the runtime never loads. ProjectPriFileName pins the conventional name. See microsoft-ui-xaml#10856.
<EnableMsixTooling>true</EnableMsixTooling>
<ProjectPriFileName>resources.pri</ProjectPriFileName>

After: publish ships resources.pri (1.4 MB, all XBF); the app launches to the shell. (Ruled out R2R along the way — both R2R on/off crashed identically.)

2. Tray menu "Show Snipdeck" and "Exit" did nothing

In an unpackaged app, H.NotifyIcon's default context menu is a native Win32 PopupMenu, built from the MenuFlyout by invoking each item's Command — it does not raise the WinUI routed Click event the items were wired to. (Left-click worked because it already used a Command.) Switched the items to the existing RelayCommand.

Diagnostics

CrashLog now always logs HRESULT and Exception.Data — the WinRT RestrictedDescription in Data is what pinpointed the missing resource (Message was only "XAML parsing failed").

🤖 Generated with Claude Code

StuartMeeks and others added 2 commits June 8, 2026 09:53
Published (Velopack) builds crashed at startup with a XamlParseException
on the first app-specific page (ShellPage), while running from Visual
Studio worked. Root cause: the self-contained Release publish shipped no
app resources.pri.

Two compounding defects:
- `dotnet publish` generated the app's PRI into bin but never copied it to
  the publish output, because the WinUI PRI/packaging targets weren't
  imported. `EnableMsixTooling=true` (required for unpackaged self-contained
  WinUI per the Windows App SDK docs) wires in the copy-to-publish step.
- An unpackaged app's runtime auto-loads only `resources.pri` from the exe
  directory, but the build names the app PRI after the assembly
  (Snipdeck.App.pri), which the runtime never loads. `ProjectPriFileName`
  pins the conventional name. See microsoft-ui-xaml#10856.

Verified on the Win11 build host: with both set, the published
self-contained Release build (R2R on, exact CI config) ships resources.pri
and launches to the shell instead of crashing.

Also surface HRESULT and Exception.Data on every logged exception in
CrashLog — the XamlParseException's RestrictedDescription in Data is what
pinpointed the missing resource (Message was only "XAML parsing failed").

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The tray "Show Snipdeck" and "Exit" menu items did nothing when clicked.
In an unpackaged app H.NotifyIcon's default context menu is a native Win32
PopupMenu, built from the MenuFlyout by invoking each item's Command — it
does not raise the WinUI routed Click event the items were wired to. (The
left-click action worked because it already used a Command.)

Drive the items via the existing RelayCommand instead of Click handlers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@StuartMeeks StuartMeeks changed the title Fix installed builds crashing on launch: ship app resources.pri Fix installed-build launch crash (resources.pri) and dead tray menu items Jun 8, 2026
@StuartMeeks StuartMeeks merged commit 24940fd into main Jun 8, 2026
6 checks passed
@StuartMeeks StuartMeeks deleted the fix/publish-missing-resources-pri branch June 8, 2026 10:02
@StuartMeeks StuartMeeks mentioned this pull request Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant