From 02d9130d0bed73d079e32014673e3c3e300e68ca Mon Sep 17 00:00:00 2001 From: Stuart Meeks Date: Mon, 8 Jun 2026 09:53:49 +0000 Subject: [PATCH 1/2] Fix installed builds crashing on launch: ship app resources.pri MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- CHANGELOG.md | 6 ++++++ src/Snipdeck.App/CrashLog.cs | 15 +++++++++------ src/Snipdeck.App/Snipdeck.App.csproj | 12 ++++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62956ff..fa25b09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Installed (Velopack) builds crashed on launch with a blank window — the published app + was missing its resource index (`resources.pri`), so the first screen failed with a + XAML parsing error. The published build now ships the app's resources correctly, and + launches as expected. Running from Visual Studio was unaffected. + ## [1.0.2] - 2026-06-08 ### Added diff --git a/src/Snipdeck.App/CrashLog.cs b/src/Snipdeck.App/CrashLog.cs index ef8962f..5a45bc1 100644 --- a/src/Snipdeck.App/CrashLog.cs +++ b/src/Snipdeck.App/CrashLog.cs @@ -1,5 +1,4 @@ using System.Globalization; -using System.Runtime.InteropServices; using System.Text; using Microsoft.Extensions.DependencyInjection; @@ -88,11 +87,8 @@ private static void AppendException(StringBuilder sb, Exception ex, int depth) var indent = new string(' ', depth * 2); _ = sb.Append(indent).Append("Type: ").AppendLine(ex.GetType().FullName ?? ex.GetType().Name); - if (ex is COMException) - { - _ = sb.Append(indent).Append("HRESULT: 0x") - .AppendLine(ex.HResult.ToString("X8", CultureInfo.InvariantCulture)); - } + _ = sb.Append(indent).Append("HRESULT: 0x") + .AppendLine(ex.HResult.ToString("X8", CultureInfo.InvariantCulture)); _ = sb.Append(indent).Append("Message: ").AppendLine(ex.Message); if (!string.IsNullOrEmpty(ex.Source)) { @@ -106,6 +102,13 @@ private static void AppendException(StringBuilder sb, Exception ex, int depth) _ = sb.Append(indent).Append(" ").AppendLine(line.TrimEnd('\r')); } } + // WinRT-sourced exceptions (e.g. XamlParseException) carry the real + // detail here, not in Message — the RestrictedDescription is what + // names the missing resource / failing element. + foreach (System.Collections.DictionaryEntry entry in ex.Data) + { + _ = sb.Append(indent).Append("Data[").Append(entry.Key).Append("]: ").AppendLine(entry.Value?.ToString()); + } if (ex.InnerException is not null) { _ = sb.Append(indent).AppendLine("Inner:"); diff --git a/src/Snipdeck.App/Snipdeck.App.csproj b/src/Snipdeck.App/Snipdeck.App.csproj index 00c2205..96f9068 100644 --- a/src/Snipdeck.App/Snipdeck.App.csproj +++ b/src/Snipdeck.App/Snipdeck.App.csproj @@ -11,6 +11,18 @@ false None true + + true + + resources.pri x64