diff --git a/src/UniGetUI.Avalonia/Infrastructure/AvaloniaAppHost.cs b/src/UniGetUI.Avalonia/Infrastructure/AvaloniaAppHost.cs index d047aa694..a46779901 100644 --- a/src/UniGetUI.Avalonia/Infrastructure/AvaloniaAppHost.cs +++ b/src/UniGetUI.Avalonia/Infrastructure/AvaloniaAppHost.cs @@ -1,6 +1,8 @@ +using System.Runtime.InteropServices; using Avalonia; using UniGetUI.Core.Data; using UniGetUI.Core.Logging; +using UniGetUI.Core.Tools; using UniGetUI.Interface; namespace UniGetUI.Avalonia.Infrastructure; @@ -43,6 +45,27 @@ public static void Run(string[] args) CoreData.WasDaemon = CoreData.IsDaemon = args.Contains(AvaloniaCliHandler.DAEMON); + string textart = $""" + __ __ _ ______ __ __ ______ + / / / /___ (_) ____/__ / /_/ / / / _/ + / / / / __ \/ / / __/ _ \/ __/ / / // / + / /_/ / / / / / /_/ / __/ /_/ /_/ // / + \____/_/ /_/_/\____/\___/\__/\____/___/ + Welcome to UniGetUI Version {CoreData.VersionName} + """; + + Logger.ImportantInfo(textart); + Logger.ImportantInfo(" "); + Logger.ImportantInfo($"Build {CoreData.BuildNumber}"); + Logger.ImportantInfo("UI Framework: Avalonia"); + Logger.ImportantInfo($"Data directory {CoreData.UniGetUIDataDirectory}"); + Logger.ImportantInfo($"OS: {RuntimeInformation.OSDescription}"); + Logger.ImportantInfo($"Process arch: {RuntimeInformation.ProcessArchitecture} (OS: {RuntimeInformation.OSArchitecture})"); + Logger.ImportantInfo($"Runtime: {RuntimeInformation.FrameworkDescription}"); + Logger.ImportantInfo($"Elevated: {CoreTools.IsAdministrator()}"); + Logger.ImportantInfo($"Packaged (MSIX): {CoreTools.IsPackagedApp()}"); + Logger.ImportantInfo($"Args: {(args.Length > 0 ? string.Join(" ", args) : "(none)")}"); + if (!TryRegisterSingleInstance(args)) { return; diff --git a/src/UniGetUI.Core.Tools/Tools.cs b/src/UniGetUI.Core.Tools/Tools.cs index df054d383..74ec86a1d 100644 --- a/src/UniGetUI.Core.Tools/Tools.cs +++ b/src/UniGetUI.Core.Tools/Tools.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.Net; using System.Net.NetworkInformation; +using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Security.Principal; using System.Text; @@ -291,6 +292,34 @@ public static bool IsAdministrator() } } + /// + /// Checks whether the current process is running inside an MSIX package (Store / sideloaded). + /// + /// True when packaged, false when running unpackaged or on a non-Windows platform. + public static bool IsPackagedApp() + { + if (!OperatingSystem.IsWindows()) + { + return false; + } + + try + { + int len = 0; + int rc = GetCurrentPackageFullName(ref len, IntPtr.Zero); + return rc != APPMODEL_ERROR_NO_PACKAGE; + } + catch + { + return false; + } + } + + private const int APPMODEL_ERROR_NO_PACKAGE = 15700; + + [DllImport("kernel32.dll", SetLastError = false)] + private static extern int GetCurrentPackageFullName(ref int packageFullNameLength, IntPtr packageFullName); + public static Task GetFileSizeAsLongAsync(Uri? url) => Task.Run(() => GetFileSizeAsLong(url)); diff --git a/src/UniGetUI/EntryPoint.cs b/src/UniGetUI/EntryPoint.cs index fd8e85187..f00cf9d6f 100644 --- a/src/UniGetUI/EntryPoint.cs +++ b/src/UniGetUI/EntryPoint.cs @@ -1,8 +1,10 @@ +using System.Runtime.InteropServices; using Microsoft.UI.Dispatching; using Microsoft.UI.Xaml; using Microsoft.Windows.AppLifecycle; using UniGetUI.Core.Data; using UniGetUI.Core.Logging; +using UniGetUI.Core.Tools; using UniGetUI.Interface; using UniGetUI.Shared; @@ -89,8 +91,16 @@ Welcome to UniGetUI Version {CoreData.VersionName} Logger.ImportantInfo(textart); Logger.ImportantInfo(" "); Logger.ImportantInfo($"Build {CoreData.BuildNumber}"); + Logger.ImportantInfo("UI Framework: WinUI 3"); Logger.ImportantInfo($"Data directory {CoreData.UniGetUIDataDirectory}"); Logger.ImportantInfo($"Encoding Code Page set to {CoreData.CODE_PAGE}"); + Logger.ImportantInfo($"OS: {RuntimeInformation.OSDescription}"); + Logger.ImportantInfo($"Process arch: {RuntimeInformation.ProcessArchitecture} (OS: {RuntimeInformation.OSArchitecture})"); + Logger.ImportantInfo($"Runtime: {RuntimeInformation.FrameworkDescription}"); + Logger.ImportantInfo($"Elevated: {CoreTools.IsAdministrator()}"); + Logger.ImportantInfo($"Packaged (MSIX): {CoreTools.IsPackagedApp()}"); + string[] cmdArgs = Environment.GetCommandLineArgs(); + Logger.ImportantInfo($"Args: {(cmdArgs.Length > 1 ? string.Join(" ", cmdArgs.Skip(1)) : "(none)")}"); // WinRT single-instance fancy stuff WinRT.ComWrappersSupport.InitializeComWrappers();