diff --git a/SPTInstaller/App.axaml.cs b/SPTInstaller/App.axaml.cs index 4c11cef..cd3978a 100644 --- a/SPTInstaller/App.axaml.cs +++ b/SPTInstaller/App.axaml.cs @@ -1,4 +1,5 @@ -using Avalonia; +using System.Linq; +using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; using ReactiveUI; @@ -36,6 +37,12 @@ public partial class App : Application { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { + if (desktop.Args != null && desktop.Args.Any(x => x.ToLower() == "debug")) + { + System.Diagnostics.Trace.Listeners.Add(new SerilogTraceListener.SerilogTraceListener()); + Log.Debug("TraceListener is registered"); + } + desktop.MainWindow = new MainWindow { DataContext = new MainWindowViewModel(), diff --git a/SPTInstaller/Models/InstallerUpdateInfo.cs b/SPTInstaller/Models/InstallerUpdateInfo.cs index bb5769c..176e79d 100644 --- a/SPTInstaller/Models/InstallerUpdateInfo.cs +++ b/SPTInstaller/Models/InstallerUpdateInfo.cs @@ -99,8 +99,13 @@ public class InstallerUpdateInfo : ReactiveObject return file.FullName; } - private void EndCheck(string infoText, bool updateAvailable) + private void EndCheck(string infoText, bool updateAvailable, bool log = true) { + if (log) + { + Log.Information(infoText); + } + UpdateInfoText = infoText; if (!updateAvailable) @@ -138,7 +143,7 @@ public class InstallerUpdateInfo : ReactiveObject if (releases == null || releases.Count == 0) { - EndCheck("No updates available", false); + EndCheck("No releases available", false); return; } @@ -146,7 +151,7 @@ public class InstallerUpdateInfo : ReactiveObject if (latest == null) { - EndCheck("No updates available", false); + EndCheck("could not get latest release", false); return; } @@ -168,7 +173,7 @@ public class InstallerUpdateInfo : ReactiveObject } catch (Exception ex) { - EndCheck(ex.Message, false); + EndCheck(ex.Message, false, false); Log.Error(ex, "Failed to check for updates"); } diff --git a/SPTInstaller/Program.cs b/SPTInstaller/Program.cs index 2734524..e546d45 100644 --- a/SPTInstaller/Program.cs +++ b/SPTInstaller/Program.cs @@ -10,6 +10,7 @@ using SPTInstaller.Interfaces; using SPTInstaller.Models; using System.Linq; using System.Reflection; +using Serilog; namespace SPTInstaller; @@ -19,8 +20,18 @@ internal class Program // SynchronizationContext-reliant code before AppMain is called: things aren't initialized // yet and stuff might break. [STAThread] - public static void Main(string[] args) => BuildAvaloniaApp() - .StartWithClassicDesktopLifetime(args); + public static void Main(string[] args) + { + try + { + BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + } + catch (Exception ex) + { + Log.Fatal(ex, "Installer closed unexpectedly"); + } + } // Avalonia configuration, don't remove; also used by visual designer. public static AppBuilder BuildAvaloniaApp() diff --git a/SPTInstaller/SPTInstaller.csproj b/SPTInstaller/SPTInstaller.csproj index 4500b7e..1f955e6 100644 --- a/SPTInstaller/SPTInstaller.csproj +++ b/SPTInstaller/SPTInstaller.csproj @@ -9,8 +9,8 @@ icon.ico Assets\icon.ico Debug;Release;TEST - 2.19 - 2.19 + 2.20 + 2.20 SPT-AKI @@ -41,6 +41,7 @@ +