Files
AppKit/samples/AppKit.Sample.Wpf/Program.cs
T
james.maesandCodex 8cbd3d1154 fix(samples): keep Velopack startup visible to its packer
Call VelopackApp.Build().Run() directly in both sample entry points and the
README integration example. The packer cannot recognize the indirect wrapper.
Retain VelopackStartup for compatibility and document the static-check limit.

Validation: zero-warning x64 solution build, solution formatting, fourteen UI
tests across both samples. Real starter packing accepts the direct call.

Refs: #11, #20, #21
Co-Authored-By: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: James Maes <james@kof22.com>
2026-10-10 15:50:01 -05:00

46 lines
1.5 KiB
C#

/*
* Copyright (c) 2026 James Maes (KofTwentyTwo)
* SPDX-License-Identifier: MIT
*/
using System.Windows;
using KofTwentyTwo.AppKit.Logging;
using KofTwentyTwo.AppKit.Wpf;
using Microsoft.Extensions.Logging;
using Velopack;
namespace AppKit.Sample.Wpf;
/// <summary>Entry point: Velopack hooks first, then the WPF application.</summary>
public static partial class Program
{
/// <summary>The app-wide activity log.</summary>
internal static IActivityLog Log { get; } = FileActivityLog.ForApp(SampleApp.Info, SampleApp.Paths);
/// <summary>The shared structured logger, including scopes.</summary>
internal static ILogger Logger { get; } = Log.AsLogger();
/// <summary>Runs Velopack&apos;s install and update hooks first, then creates the WPF application with AppKit&apos;s crash net and theme and shows the main window.</summary>
[STAThread]
private static void Main()
{
// vpk checks the entry assembly for this direct call before packaging.
VelopackApp.Build().Run();
var app = new Application { ShutdownMode = ShutdownMode.OnMainWindowClose };
WpfShell.InstallCrashNet(app, () => Log);
WpfShell.ApplyTheme(app, SampleApp.SettingsStore.Load().ThemeKind);
LogStarted(Logger, SampleApp.Info.DisplayName);
app.Run(new MainWindow());
}
/// <summary>Records startup with the app identity as a field.</summary>
[LoggerMessage(100, LogLevel.Information, "{AppName} (WPF) started.")]
private static partial void LogStarted(ILogger logger, string appName);
}