diff --git a/Wabbajack.Downloaders.Nexus/Wabbajack.Downloaders.Nexus.csproj b/Wabbajack.Downloaders.Nexus/Wabbajack.Downloaders.Nexus.csproj index 2ead5edb..96c12049 100644 --- a/Wabbajack.Downloaders.Nexus/Wabbajack.Downloaders.Nexus.csproj +++ b/Wabbajack.Downloaders.Nexus/Wabbajack.Downloaders.Nexus.csproj @@ -17,9 +17,4 @@ - - - - - diff --git a/Wabbajack.Launcher/ViewModels/MainWindowViewModel.cs b/Wabbajack.Launcher/ViewModels/MainWindowViewModel.cs index c57c81e6..a1311a6c 100644 --- a/Wabbajack.Launcher/ViewModels/MainWindowViewModel.cs +++ b/Wabbajack.Launcher/ViewModels/MainWindowViewModel.cs @@ -9,6 +9,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.Threading; using System.Threading.Tasks; +using MessageBox.Avalonia.DTO; using ReactiveUI.Fody.Helpers; using Wabbajack.Compression.Zip; using Wabbajack.Downloaders.Http; @@ -172,14 +173,38 @@ public class MainWindowViewModel : ViewModelBase private async Task VerifyCurrentLocation() { - var entryPoint = KnownFolders.EntryPoint; - if (entryPoint.FileName == "Desktop".ToRelativePath() - || entryPoint.Depth <= 1 - || entryPoint.FileName == "Downloads".ToRelativePath()) + try { + var entryPoint = KnownFolders.EntryPoint; + if (entryPoint.FileName == "Desktop".ToRelativePath() + || entryPoint.Depth <= 1 + || entryPoint.FileName == "Downloads".ToRelativePath()) + { + + var msg = MessageBox.Avalonia.MessageBoxManager + .GetMessageBoxStandardWindow(new MessageBoxStandardParams() + { + Topmost = true, + ShowInCenter = true, + ContentTitle = "Wabbajack Launcher: Bad startup path", + ContentMessage = + "Cannot start in the root, Downloads or Desktop folders.\nPlease move Wabbajack to another folder." + }); + var result = await msg.Show(); + Environment.Exit(1); + } + } + catch (Exception ex) + { + Status = ex.Message; var msg = MessageBox.Avalonia.MessageBoxManager - .GetMessageBoxStandardWindow("Bad Download Path", - "Cannot start in the root, Downloads or Desktop folders."); + .GetMessageBoxStandardWindow(new MessageBoxStandardParams() + { + Topmost = true, + ShowInCenter = true, + ContentTitle = "Wabbajack Launcher: Error", + ContentMessage = ex.ToString() + }); var result = await msg.Show(); Environment.Exit(1); } diff --git a/Wabbajack.Networking.Steam.Test/Wabbajack.Networking.Steam.Test.csproj b/Wabbajack.Networking.Steam.Test/Wabbajack.Networking.Steam.Test.csproj index 275bc9cd..05f8b01e 100644 --- a/Wabbajack.Networking.Steam.Test/Wabbajack.Networking.Steam.Test.csproj +++ b/Wabbajack.Networking.Steam.Test/Wabbajack.Networking.Steam.Test.csproj @@ -11,6 +11,8 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/Wabbajack.Paths.IO/KnownFolders.cs b/Wabbajack.Paths.IO/KnownFolders.cs index 2c45f5a1..59c44222 100644 --- a/Wabbajack.Paths.IO/KnownFolders.cs +++ b/Wabbajack.Paths.IO/KnownFolders.cs @@ -11,13 +11,15 @@ public static class KnownFolders { get { - var result = Process.GetCurrentProcess().MainModule!.FileName!.ToAbsolutePath().Parent; - if (result.FileName == "dotnet".ToRelativePath() || Assembly.GetEntryAssembly() != null) + var result = Process.GetCurrentProcess().MainModule?.FileName?.ToAbsolutePath() ?? default; + + + if ((result != default && result.Depth > 1 && result.FileName == "dotnet".ToRelativePath()) || Assembly.GetEntryAssembly() != null) { - return Assembly.GetExecutingAssembly().Location.ToAbsolutePath().Parent; + result = Assembly.GetEntryAssembly()!.Location.ToAbsolutePath(); } - return result; + return result == default ? Environment.CurrentDirectory.ToAbsolutePath() : result.Parent; } } diff --git a/Wabbajack.Paths/AbsolutePath.cs b/Wabbajack.Paths/AbsolutePath.cs index 959c9f13..42f6c0bb 100644 --- a/Wabbajack.Paths/AbsolutePath.cs +++ b/Wabbajack.Paths/AbsolutePath.cs @@ -20,7 +20,7 @@ public struct AbsolutePath : IPath, IComparable, IEquatable Extension.FromPath(Parts[^1]); - public RelativePath FileName => (RelativePath) Parts[^1]; + public RelativePath FileName => new(Parts[^1..]); internal AbsolutePath(string[] parts, PathFormat format) {