From ff082e9fbe32388b2e581e64709e3e4c8d0c7fe4 Mon Sep 17 00:00:00 2001 From: indigo-san Date: Sat, 19 Aug 2023 22:34:12 +0900 Subject: [PATCH] chore --- src/Beutl.Api/Services/CoreLibraries.cs | 4 +++- src/Beutl.PackageTools/Program.cs | 22 +++++++++++++++++++ src/Beutl/Beutl.csproj | 1 + .../Services/UnhandledExceptionHandler.cs | 5 ++++- src/Beutl/ViewModels/MainViewModel.cs | 5 ++++- 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/Beutl.Api/Services/CoreLibraries.cs b/src/Beutl.Api/Services/CoreLibraries.cs index 89eb5be00..5dbeef931 100644 --- a/src/Beutl.Api/Services/CoreLibraries.cs +++ b/src/Beutl.Api/Services/CoreLibraries.cs @@ -76,6 +76,7 @@ public static IEnumerable CollectRuntimeDependencies() case "Beutl.Utilities": case "Beutl.WaitingDialog": case "bpt": + case "Beutl.ExceptionHandler": version = assembly.GetName().Version!.ToString(); break; default: @@ -83,7 +84,8 @@ public static IEnumerable CollectRuntimeDependencies() } } - library.Add(new Dependency(fileName, version!)); + if (version != null) + library.Add(new Dependency(fileName, version)); } } } diff --git a/src/Beutl.PackageTools/Program.cs b/src/Beutl.PackageTools/Program.cs index 83aa0683b..bde992a38 100644 --- a/src/Beutl.PackageTools/Program.cs +++ b/src/Beutl.PackageTools/Program.cs @@ -1,4 +1,5 @@ using System.CommandLine; +using System.Diagnostics; using Beutl.PackageTools; using Beutl.PackageTools.Properties; @@ -23,11 +24,16 @@ { IsHidden = true, }; +var launchDebugger = new Option("--launch-debugger", () => false) +{ + IsHidden = true, +}; var rootCommand = new RunCommand(apiApp, verbose, clean); rootCommand.AddGlobalOption(verbose); rootCommand.AddGlobalOption(clean); rootCommand.AddGlobalOption(stayOpen); +rootCommand.AddGlobalOption(launchDebugger); rootCommand.AddCommand(new InstallCommand(apiApp, verbose, clean)); rootCommand.AddCommand(new UninstallCommand(apiApp, verbose, clean)); rootCommand.AddCommand(new UpdateCommand(apiApp, verbose, clean)); @@ -35,6 +41,22 @@ rootCommand.AddCommand(new ListCommand(apiApp, verbose)); bool stayOpenValue = rootCommand.Parse(args).GetValueForOption(stayOpen); +bool launchDebuggerValue = rootCommand.Parse(args).GetValueForOption(launchDebugger); + +#if DEBUG +if (!Debugger.IsAttached && launchDebuggerValue) +{ + while (true) + { + Thread.Sleep(100); + + if (Debugger.Launch()) + break; + } +} +#endif + + await rootCommand.InvokeAsync(args); if (stayOpenValue) diff --git a/src/Beutl/Beutl.csproj b/src/Beutl/Beutl.csproj index 823d609e8..e43ca526b 100644 --- a/src/Beutl/Beutl.csproj +++ b/src/Beutl/Beutl.csproj @@ -52,6 +52,7 @@ + diff --git a/src/Beutl/Services/UnhandledExceptionHandler.cs b/src/Beutl/Services/UnhandledExceptionHandler.cs index 25fc392c7..b101a8e84 100644 --- a/src/Beutl/Services/UnhandledExceptionHandler.cs +++ b/src/Beutl/Services/UnhandledExceptionHandler.cs @@ -38,7 +38,10 @@ private static void OnUnhandledException(object sender, UnhandledExceptionEventA PrivateExit(); - Process.Start(new ProcessStartInfo(Path.Combine(AppContext.BaseDirectory, "Beutl.ExceptionHandler")) + string exePath = Path.Combine( + AppContext.BaseDirectory, + OperatingSystem.IsWindows() ? "Beutl.ExceptionHandler.exe" : "Beutl.ExceptionHandler"); + Process.Start(new ProcessStartInfo(exePath) { UseShellExecute = true, }); diff --git a/src/Beutl/ViewModels/MainViewModel.cs b/src/Beutl/ViewModels/MainViewModel.cs index 912de1d4b..fe009943f 100644 --- a/src/Beutl/ViewModels/MainViewModel.cs +++ b/src/Beutl/ViewModels/MainViewModel.cs @@ -524,7 +524,7 @@ private void OnExit(object? sender, ControlledApplicationLifetimeExitEventArgs e if (installs.Length > 0 || uninstalls.Length > 0) { - var startInfo = new ProcessStartInfo(Path.Combine(AppContext.BaseDirectory, "bpt")) + var startInfo = new ProcessStartInfo(Path.Combine(AppContext.BaseDirectory, OperatingSystem.IsWindows() ? "bpt.exe" : "bpt")) { UseShellExecute = true, }; @@ -550,6 +550,9 @@ private void OnExit(object? sender, ControlledApplicationLifetimeExitEventArgs e startInfo.ArgumentList.Add("--verbose"); startInfo.ArgumentList.Add("--stay-open"); + if (Debugger.IsAttached) + startInfo.ArgumentList.Add("--launch-debugger"); + Process.Start(startInfo); } }