Skip to content

Commit e150bd5

Browse files
authored
Fixed the browser not opening on Linux and macOS.
Fixed the browser not opening on Linux and macOS.
2 parents 0c0208a + 6b98183 commit e150bd5

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

MinecraftClient/Protocol/MicrosoftAuthentication.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Text.RegularExpressions;
66
using System.Collections.Specialized;
77
using System.Diagnostics;
8+
using System.Runtime.InteropServices;
89

910
namespace MinecraftClient.Protocol
1011
{
@@ -91,7 +92,28 @@ public static void OpenBrowser(string link)
9192
{
9293
try
9394
{
94-
Process.Start(link);
95+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
96+
{
97+
var ps = new ProcessStartInfo(link)
98+
{
99+
UseShellExecute = true,
100+
Verb = "open"
101+
};
102+
103+
Process.Start(ps);
104+
}
105+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
106+
{
107+
Process.Start("xdg-open", link);
108+
}
109+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
110+
{
111+
Process.Start("open", link);
112+
}
113+
else
114+
{
115+
ConsoleIO.WriteLine("Platform not supported, open up the link manually: " + link);
116+
}
95117
}
96118
catch (Exception e)
97119
{

0 commit comments

Comments
 (0)