Skip to content

Commit d147bf7

Browse files
committed
added some line to application log
1 parent 2de7aae commit d147bf7

3 files changed

Lines changed: 62 additions & 0 deletions

File tree

src/UniGetUI.Avalonia/Infrastructure/AvaloniaAppHost.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
using System.Runtime.InteropServices;
12
using Avalonia;
23
using UniGetUI.Core.Data;
34
using UniGetUI.Core.Logging;
5+
using UniGetUI.Core.Tools;
46
using UniGetUI.Interface;
57

68
namespace UniGetUI.Avalonia.Infrastructure;
@@ -43,6 +45,27 @@ public static void Run(string[] args)
4345

4446
CoreData.WasDaemon = CoreData.IsDaemon = args.Contains(AvaloniaCliHandler.DAEMON);
4547

48+
string textart = $"""
49+
__ __ _ ______ __ __ ______
50+
/ / / /___ (_) ____/__ / /_/ / / / _/
51+
/ / / / __ \/ / / __/ _ \/ __/ / / // /
52+
/ /_/ / / / / / /_/ / __/ /_/ /_/ // /
53+
\____/_/ /_/_/\____/\___/\__/\____/___/
54+
Welcome to UniGetUI Version {CoreData.VersionName}
55+
""";
56+
57+
Logger.ImportantInfo(textart);
58+
Logger.ImportantInfo(" ");
59+
Logger.ImportantInfo($"Build {CoreData.BuildNumber}");
60+
Logger.ImportantInfo("UI Framework: Avalonia");
61+
Logger.ImportantInfo($"Data directory {CoreData.UniGetUIDataDirectory}");
62+
Logger.ImportantInfo($"OS: {RuntimeInformation.OSDescription}");
63+
Logger.ImportantInfo($"Process arch: {RuntimeInformation.ProcessArchitecture} (OS: {RuntimeInformation.OSArchitecture})");
64+
Logger.ImportantInfo($"Runtime: {RuntimeInformation.FrameworkDescription}");
65+
Logger.ImportantInfo($"Elevated: {CoreTools.IsAdministrator()}");
66+
Logger.ImportantInfo($"Packaged (MSIX): {CoreTools.IsPackagedApp()}");
67+
Logger.ImportantInfo($"Args: {(args.Length > 0 ? string.Join(" ", args) : "(none)")}");
68+
4669
if (!TryRegisterSingleInstance(args))
4770
{
4871
return;

src/UniGetUI.Core.Tools/Tools.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Diagnostics;
33
using System.Net;
44
using System.Net.NetworkInformation;
5+
using System.Runtime.InteropServices;
56
using System.Security.Cryptography;
67
using System.Security.Principal;
78
using System.Text;
@@ -291,6 +292,34 @@ public static bool IsAdministrator()
291292
}
292293
}
293294

295+
/// <summary>
296+
/// Checks whether the current process is running inside an MSIX package (Store / sideloaded).
297+
/// </summary>
298+
/// <returns>True when packaged, false when running unpackaged or on a non-Windows platform.</returns>
299+
public static bool IsPackagedApp()
300+
{
301+
if (!OperatingSystem.IsWindows())
302+
{
303+
return false;
304+
}
305+
306+
try
307+
{
308+
int len = 0;
309+
int rc = GetCurrentPackageFullName(ref len, IntPtr.Zero);
310+
return rc != APPMODEL_ERROR_NO_PACKAGE;
311+
}
312+
catch
313+
{
314+
return false;
315+
}
316+
}
317+
318+
private const int APPMODEL_ERROR_NO_PACKAGE = 15700;
319+
320+
[DllImport("kernel32.dll", SetLastError = false)]
321+
private static extern int GetCurrentPackageFullName(ref int packageFullNameLength, IntPtr packageFullName);
322+
294323
public static Task<long> GetFileSizeAsLongAsync(Uri? url) =>
295324
Task.Run(() => GetFileSizeAsLong(url));
296325

src/UniGetUI/EntryPoint.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
using System.Runtime.InteropServices;
12
using Microsoft.UI.Dispatching;
23
using Microsoft.UI.Xaml;
34
using Microsoft.Windows.AppLifecycle;
45
using UniGetUI.Core.Data;
56
using UniGetUI.Core.Logging;
7+
using UniGetUI.Core.Tools;
68
using UniGetUI.Interface;
79
using UniGetUI.Shared;
810

@@ -89,8 +91,16 @@ Welcome to UniGetUI Version {CoreData.VersionName}
8991
Logger.ImportantInfo(textart);
9092
Logger.ImportantInfo(" ");
9193
Logger.ImportantInfo($"Build {CoreData.BuildNumber}");
94+
Logger.ImportantInfo("UI Framework: WinUI 3");
9295
Logger.ImportantInfo($"Data directory {CoreData.UniGetUIDataDirectory}");
9396
Logger.ImportantInfo($"Encoding Code Page set to {CoreData.CODE_PAGE}");
97+
Logger.ImportantInfo($"OS: {RuntimeInformation.OSDescription}");
98+
Logger.ImportantInfo($"Process arch: {RuntimeInformation.ProcessArchitecture} (OS: {RuntimeInformation.OSArchitecture})");
99+
Logger.ImportantInfo($"Runtime: {RuntimeInformation.FrameworkDescription}");
100+
Logger.ImportantInfo($"Elevated: {CoreTools.IsAdministrator()}");
101+
Logger.ImportantInfo($"Packaged (MSIX): {CoreTools.IsPackagedApp()}");
102+
string[] cmdArgs = Environment.GetCommandLineArgs();
103+
Logger.ImportantInfo($"Args: {(cmdArgs.Length > 1 ? string.Join(" ", cmdArgs.Skip(1)) : "(none)")}");
94104

95105
// WinRT single-instance fancy stuff
96106
WinRT.ComWrappersSupport.InitializeComWrappers();

0 commit comments

Comments
 (0)