diff --git a/Updator.Downloader.UI/App.cs b/Updator.Downloader.UI/App.cs index 62a8a3a..2bcf5f8 100644 --- a/Updator.Downloader.UI/App.cs +++ b/Updator.Downloader.UI/App.cs @@ -11,19 +11,7 @@ public static class App { public static string AppLocalDataFolder => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Reito", "Updator"); - static App() { - if (OperatingSystem.IsMacOS()) { - var pwd = Process.GetCurrentProcess().MainModule?.FileName; - if (!string.IsNullOrWhiteSpace(pwd)) { - var match = ".app/Contents/MacOS"; - if (pwd.Contains(match)) { - pwd = pwd[..pwd.IndexOf(match, StringComparison.Ordinal)]; - pwd = pwd[..pwd.LastIndexOf('/')]; - Environment.CurrentDirectory = pwd; - } - } - } - + static App() { Directory.CreateDirectory(AppLocalDataFolder); LogFactory = LoggerFactory.Create(builder => { builder.AddSimpleConsole(o => { diff --git a/Updator.Downloader.UI/Program.cs b/Updator.Downloader.UI/Program.cs index 1514f0f..6c26dd8 100644 --- a/Updator.Downloader.UI/Program.cs +++ b/Updator.Downloader.UI/Program.cs @@ -21,6 +21,19 @@ public static void Main(string[] args) { App.AppLog.LogInformation($"启动器 {Meta.RuntimeString} {Meta.RuntimeVersion}"); App.AppLog.LogInformation($"工作目录 {Environment.CurrentDirectory}"); + + if (OperatingSystem.IsMacOS()) { + var pwd = Process.GetCurrentProcess().MainModule?.FileName; + if (!string.IsNullOrWhiteSpace(pwd)) { + var match = ".app/Contents/MacOS"; + if (pwd.Contains(match)) { + pwd = pwd[..pwd.IndexOf(match, StringComparison.Ordinal)]; + pwd = pwd[..pwd.LastIndexOf('/')]; + Environment.CurrentDirectory = pwd; + App.AppLog.LogInformation($"改变工作目录 {Environment.CurrentDirectory}"); + } + } + } var parsed = new Parser(a => { a.AllowMultiInstance = true;