Printing/Pdf: Fix detection of WinziPrint.exe to isolate tests properly
All checks were successful
Test / Run tests (push) Successful in 2m11s

This commit is contained in:
2026-01-16 01:26:35 +01:00
parent 42121fe7da
commit 640dbf705e

View File

@@ -7,6 +7,7 @@ using System.Drawing.Printing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net.Sockets; using System.Net.Sockets;
using System.Reflection;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -15,11 +16,13 @@ using System.Windows;
namespace Elwig.Helpers.Printing { namespace Elwig.Helpers.Printing {
public static class Pdf { public static class Pdf {
private static readonly string WinziPrint = new string[] { App.InstallPath } private static readonly string WinziPrint = (Assembly.GetEntryAssembly()?.Location.Contains(@"\bin\") ?? false) ?
.Union(Environment.GetEnvironmentVariable("PATH")?.Split(';') ?? []) Path.Combine(Assembly.GetEntryAssembly()!.Location.Split(@"\bin\")[0], "../Installer/Files/WinziPrint.exe") :
.Select(x => Path.Combine(x, "WinziPrint.exe")) new string[] { App.InstallPath }
.Where(File.Exists) .Union(Environment.GetEnvironmentVariable("PATH")?.Split(';') ?? [])
.FirstOrDefault() ?? throw new FileNotFoundException("WiniPrint executable not found"); .Select(x => Path.Combine(x, "WinziPrint.exe"))
.Where(File.Exists)
.FirstOrDefault() ?? throw new FileNotFoundException("WiniPrint executable not found");
private static Process? WinziPrintProc; private static Process? WinziPrintProc;
public static bool IsReady => WinziPrintProc != null; public static bool IsReady => WinziPrintProc != null;