From 81edbde5cc69c7f44e3e137e155375d5ade38372 Mon Sep 17 00:00:00 2001 From: LeapwardKoex Date: Thu, 14 Nov 2024 21:40:30 +1300 Subject: [PATCH] Add ability to create installer using Advanced Installer --- .github/workflows/dotnet-desktop.yml | 2 +- .gitignore | 4 +- App.xaml.cs | 2 +- Installer/Mai Touch Emulator.aip | 241 +++++++++++++++++++++++++++ Logging/DumpCreator.cs | 2 +- Logging/Logger.cs | 14 +- WpfMaiTouchEmulator.csproj | 7 +- 7 files changed, 263 insertions(+), 9 deletions(-) create mode 100644 Installer/Mai Touch Emulator.aip diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/dotnet-desktop.yml index bbdc3b3..fd75ddd 100644 --- a/.github/workflows/dotnet-desktop.yml +++ b/.github/workflows/dotnet-desktop.yml @@ -108,4 +108,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: Emulator package - path: ./bin/Release/net8.0-windows/ + path: ./bin/Release/net8.0-windows10.0.17763.0/ diff --git a/.gitignore b/.gitignore index 9491a2f..489035e 100644 --- a/.gitignore +++ b/.gitignore @@ -360,4 +360,6 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +FodyWeavers.xsd + +Installer/ diff --git a/App.xaml.cs b/App.xaml.cs index 81660d8..97f38e8 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -28,7 +28,7 @@ public partial class App : Application private void CreateDump(Exception exception) { - var dumpFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CrashDump.dmp"); + var dumpFilePath = Path.Combine(Logger.GetLogPath(), "CrashDump.dmp"); using (var fs = new FileStream(dumpFilePath, FileMode.Create)) { diff --git a/Installer/Mai Touch Emulator.aip b/Installer/Mai Touch Emulator.aip new file mode 100644 index 0000000..29a65d8 --- /dev/null +++ b/Installer/Mai Touch Emulator.aip @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Logging/DumpCreator.cs b/Logging/DumpCreator.cs index 33bef9c..f5a5b26 100644 --- a/Logging/DumpCreator.cs +++ b/Logging/DumpCreator.cs @@ -3,7 +3,7 @@ using System.Runtime.InteropServices; using System.IO; using System.Diagnostics; -class DumpCreator +public class DumpCreator { [Flags] public enum Typ : uint diff --git a/Logging/Logger.cs b/Logging/Logger.cs index 26dfb23..f371432 100644 --- a/Logging/Logger.cs +++ b/Logging/Logger.cs @@ -7,12 +7,22 @@ public static class Logger private static readonly object lockObj = new(); private static string? logFilePath; + public static string GetLogPath() + { + var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "WpfMaiTouchEmulator"); + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + return path; + } + private static string GetLogFilePath() { if (logFilePath == null) { var fileName = $"app_{DateTime.Now:yyyy-MM-dd}.log"; - logFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); + logFilePath = Path.Combine(GetLogPath(), fileName); } return logFilePath; } @@ -21,7 +31,7 @@ public static class Logger public static void CleanupOldLogFiles() { var directory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); - var oldFiles = directory.GetFiles("app_*.log") + var oldFiles = new DirectoryInfo(GetLogPath()).GetFiles("app_*.log") .Where(f => f.CreationTime < DateTime.Now.AddDays(-7)) .ToList(); diff --git a/WpfMaiTouchEmulator.csproj b/WpfMaiTouchEmulator.csproj index 4d036b7..3107519 100644 --- a/WpfMaiTouchEmulator.csproj +++ b/WpfMaiTouchEmulator.csproj @@ -2,11 +2,12 @@ WinExe - net8.0-windows + net8.0-windows10.0.17763.0 enable enable true Assets\icon.ico + x64 @@ -18,8 +19,8 @@ - - + +