From 391bdb818f4520a7214a00024ba3233474460e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Wed, 16 Jul 2025 11:08:10 -0300 Subject: [PATCH 1/3] Add support to ARM browsers --- lib/PuppeteerSharp/BrowserData/Chrome.cs | 13 +++++++------ .../BrowserData/ChromeHeadlessShell.cs | 12 ++++++------ lib/PuppeteerSharp/BrowserData/Chromium.cs | 14 +++++++------- lib/PuppeteerSharp/BrowserData/Firefox.cs | 10 ++++++---- lib/PuppeteerSharp/BrowserFetcher.cs | 5 ++++- lib/PuppeteerSharp/Platform.cs | 5 +++++ lib/PuppeteerSharp/PuppeteerSharp.csproj | 8 ++++---- 7 files changed, 39 insertions(+), 28 deletions(-) diff --git a/lib/PuppeteerSharp/BrowserData/Chrome.cs b/lib/PuppeteerSharp/BrowserData/Chrome.cs index 2aeb46519..fb45645d6 100644 --- a/lib/PuppeteerSharp/BrowserData/Chrome.cs +++ b/lib/PuppeteerSharp/BrowserData/Chrome.cs @@ -30,7 +30,7 @@ internal static string RelativeExecutablePath(Platform platform, string builId) "Contents", "MacOS", "Google Chrome for Testing"), - Platform.Linux => Path.Combine("chrome-linux64", "chrome"), + Platform.Linux or Platform.LinuxArm64 => Path.Combine("chrome-linux64", "chrome"), Platform.Win32 or Platform.Win64 => Path.Combine("chrome-" + GetFolder(platform), "chrome.exe"), _ => throw new ArgumentException("Invalid platform", nameof(platform)), }; @@ -60,6 +60,7 @@ internal static string ResolveSystemExecutablePath(Platform platform, ChromeRele ChromeReleaseChannel.Dev => $"/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome Dev", _ => throw new PuppeteerException($"{channel} is not supported"), }; + case Platform.LinuxArm64: case Platform.Linux: return channel switch { @@ -86,17 +87,17 @@ internal static string ResolveSystemExecutablePath(Platform platform, ChromeRele } private static string[] ResolveDownloadPath(Platform platform, string buildId) - => new string[] - { + => + [ buildId, GetFolder(platform), - $"chrome-{GetFolder(platform)}.zip", - }; + $"chrome-{GetFolder(platform)}.zip" + ]; private static string GetFolder(Platform platform) => platform switch { - Platform.Linux => "linux64", + Platform.Linux or Platform.LinuxArm64 => "linux64", Platform.MacOSArm64 => "mac-arm64", Platform.MacOS => "mac-x64", Platform.Win32 => "win32", diff --git a/lib/PuppeteerSharp/BrowserData/ChromeHeadlessShell.cs b/lib/PuppeteerSharp/BrowserData/ChromeHeadlessShell.cs index 6c27559b2..ee7d00488 100644 --- a/lib/PuppeteerSharp/BrowserData/ChromeHeadlessShell.cs +++ b/lib/PuppeteerSharp/BrowserData/ChromeHeadlessShell.cs @@ -17,23 +17,23 @@ internal static string RelativeExecutablePath(Platform platform, string buildId) Platform.MacOS or Platform.MacOSArm64 => Path.Combine( "chrome-headless-shell-" + GetFolder(platform), "chrome-headless-shell"), - Platform.Linux => Path.Combine("chrome-headless-shell-linux64", "chrome-headless-shell"), + Platform.Linux or Platform.LinuxArm64 => Path.Combine("chrome-headless-shell-linux64", "chrome-headless-shell"), Platform.Win32 or Platform.Win64 => Path.Combine("chrome-headless-shell-" + GetFolder(platform), "chrome-headless-shell.exe"), _ => throw new ArgumentException("Invalid platform", nameof(platform)), }; private static string[] ResolveDownloadPath(Platform platform, string buildId) - => new string[] - { + => + [ buildId, GetFolder(platform), - $"chrome-headless-shell-{GetFolder(platform)}.zip", - }; + $"chrome-headless-shell-{GetFolder(platform)}.zip" + ]; private static string GetFolder(Platform platform) => platform switch { - Platform.Linux => "linux64", + Platform.Linux or Platform.LinuxArm64 => "linux64", Platform.MacOSArm64 => "mac-arm64", Platform.MacOS => "mac-x64", Platform.Win32 => "win32", diff --git a/lib/PuppeteerSharp/BrowserData/Chromium.cs b/lib/PuppeteerSharp/BrowserData/Chromium.cs index ae6b9a58e..027db5a05 100644 --- a/lib/PuppeteerSharp/BrowserData/Chromium.cs +++ b/lib/PuppeteerSharp/BrowserData/Chromium.cs @@ -21,23 +21,23 @@ internal static string RelativeExecutablePath(Platform platform, string builId) "Contents", "MacOS", "Chromium"), - Platform.Linux => Path.Combine("chrome-linux", "chrome"), + Platform.Linux or Platform.LinuxArm64 => Path.Combine("chrome-linux", "chrome"), Platform.Win32 or Platform.Win64 => Path.Combine("chrome-win", "chrome.exe"), _ => throw new ArgumentException("Invalid platform", nameof(platform)), }; private static string[] ResolveDownloadPath(Platform platform, string buildId) - => new string[] - { + => + [ GetFolder(platform), buildId, - $"{GetArchive(platform, buildId)}.zip", - }; + $"{GetArchive(platform, buildId)}.zip" + ]; private static string GetArchive(Platform platform, string buildId) => platform switch { - Platform.Linux => "chrome-linux", + Platform.Linux or Platform.LinuxArm64 => "chrome-linux", Platform.MacOS or Platform.MacOSArm64 => "chrome-mac", // Windows archive name changed at r591479. @@ -48,7 +48,7 @@ private static string GetArchive(Platform platform, string buildId) private static string GetFolder(Platform platform) => platform switch { - Platform.Linux => "Linux_x64", + Platform.Linux or Platform.LinuxArm64 => "Linux_x64", Platform.MacOSArm64 => "Mac_Arm", Platform.MacOS => "Mac", Platform.Win32 => "Win", diff --git a/lib/PuppeteerSharp/BrowserData/Firefox.cs b/lib/PuppeteerSharp/BrowserData/Firefox.cs index e08b0676a..956104fbe 100644 --- a/lib/PuppeteerSharp/BrowserData/Firefox.cs +++ b/lib/PuppeteerSharp/BrowserData/Firefox.cs @@ -90,7 +90,7 @@ internal static string RelativeExecutablePath(Platform platform, string buildId) "Contents", "MacOS", "firefox"), - Platform.Linux => Path.Combine("firefox", "firefox"), + Platform.Linux or Platform.LinuxArm64 => Path.Combine("firefox", "firefox"), Platform.Win32 or Platform.Win64 => Path.Combine("firefox", "firefox.exe"), _ => throw new ArgumentException("Invalid platform", nameof(platform)), }; @@ -102,7 +102,7 @@ internal static string RelativeExecutablePath(Platform platform, string buildId) "Contents", "MacOS", "firefox"), - Platform.Linux => Path.Combine("firefox", "firefox"), + Platform.Linux or Platform.LinuxArm64 => Path.Combine("firefox", "firefox"), Platform.Win32 or Platform.Win64 => Path.Combine("core", "firefox.exe"), _ => throw new ArgumentException("Invalid platform", nameof(platform)), }; @@ -162,6 +162,7 @@ private static string GetPlatformNameForUrl(Platform platform) => platform switch { Platform.Linux => "linux-x86_64", + Platform.LinuxArm64 => "linux-aarch64", Platform.MacOS or Platform.MacOSArm64 => "mac", Platform.Win32 => "win32", Platform.Win64 => "win64", @@ -171,7 +172,7 @@ private static string GetPlatformNameForUrl(Platform platform) private static string GetFirefoxPlatform(Platform platform) => platform switch { - Platform.Linux => "linux", + Platform.Linux or Platform.LinuxArm64 => "linux", Platform.MacOS => "mac", Platform.MacOSArm64 => "mac_arm", Platform.Win32 => "win32", @@ -182,6 +183,7 @@ private static string GetFirefoxPlatform(Platform platform) private static string GetArchiveNightly(Platform platform, string buildId) => platform switch { + Platform.LinuxArm64 => $"firefox-{buildId}.en-US.{GetFirefoxPlatform(platform)}-aarch64.tar.{GetFormat(buildId)}", Platform.Linux => $"firefox-{buildId}.en-US.{GetFirefoxPlatform(platform)}-x86_64.tar.{GetFormat(buildId)}", Platform.MacOS or Platform.MacOSArm64 => $"firefox-{buildId}.en-US.mac.dmg", Platform.Win32 or Platform.Win64 => $"firefox-{buildId}.en-US.{GetFirefoxPlatform(platform)}.zip", @@ -197,7 +199,7 @@ private static string GetFormat(string buildId) private static string GetArchive(Platform platform, string buildId) => platform switch { - Platform.Linux => $"firefox-{buildId}.tar.bz2", + Platform.Linux or Platform.LinuxArm64 => $"firefox-{buildId}.tar.bz2", Platform.MacOS or Platform.MacOSArm64 => $"Firefox {buildId}.dmg", Platform.Win32 or Platform.Win64 => $"Firefox Setup {buildId}.exe", diff --git a/lib/PuppeteerSharp/BrowserFetcher.cs b/lib/PuppeteerSharp/BrowserFetcher.cs index 0b9059da8..eccb41e24 100644 --- a/lib/PuppeteerSharp/BrowserFetcher.cs +++ b/lib/PuppeteerSharp/BrowserFetcher.cs @@ -160,12 +160,15 @@ internal static Platform GetCurrentPlatform() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - return RuntimeInformation.OSArchitecture == Architecture.X64 ? Platform.Win64 : Platform.Win32; + return RuntimeInformation.OSArchitecture == Architecture.X64 || IsWindows11() ? Platform.Win64 : Platform.Win32; } return Platform.Unknown; } + internal static bool IsWindows11() + => RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Environment.OSVersion.Version.Build >= 22000; + internal static string GetBrowsersLocation() { var assembly = typeof(Puppeteer).Assembly; diff --git a/lib/PuppeteerSharp/Platform.cs b/lib/PuppeteerSharp/Platform.cs index b4acfca59..e24ebc235 100644 --- a/lib/PuppeteerSharp/Platform.cs +++ b/lib/PuppeteerSharp/Platform.cs @@ -25,6 +25,11 @@ public enum Platform /// Linux, + /// + /// Linux arm64. + /// + LinuxArm64, + /// /// Win32. /// diff --git a/lib/PuppeteerSharp/PuppeteerSharp.csproj b/lib/PuppeteerSharp/PuppeteerSharp.csproj index da75ef3f2..dca72cafc 100644 --- a/lib/PuppeteerSharp/PuppeteerSharp.csproj +++ b/lib/PuppeteerSharp/PuppeteerSharp.csproj @@ -12,10 +12,10 @@ Headless Browser .NET API PuppeteerSharp - 20.2.1 - 20.2.1 - 20.2.1 - 20.2.1 + 20.2.2 + 20.2.2 + 20.2.2 + 20.2.2 false false embedded From af86eb5b5ffd6611595028ea72afb2e23bea06f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Wed, 16 Jul 2025 11:13:17 -0300 Subject: [PATCH 2/3] thank you copilot --- lib/PuppeteerSharp/BrowserFetcher.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/PuppeteerSharp/BrowserFetcher.cs b/lib/PuppeteerSharp/BrowserFetcher.cs index eccb41e24..55c1d0279 100644 --- a/lib/PuppeteerSharp/BrowserFetcher.cs +++ b/lib/PuppeteerSharp/BrowserFetcher.cs @@ -160,7 +160,8 @@ internal static Platform GetCurrentPlatform() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - return RuntimeInformation.OSArchitecture == Architecture.X64 || IsWindows11() ? Platform.Win64 : Platform.Win32; + return RuntimeInformation.OSArchitecture == Architecture.X64 || + (RuntimeInformation.OSArchitecture == Architecture.Arm64 && IsWindows11()) ? Platform.Win64 : Platform.Win32; } return Platform.Unknown; From cfcbd6af335826470367b095a6fb5f4976344192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Wed, 16 Jul 2025 11:40:15 -0300 Subject: [PATCH 3/3] Update lib/PuppeteerSharp/Platform.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- lib/PuppeteerSharp/Platform.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PuppeteerSharp/Platform.cs b/lib/PuppeteerSharp/Platform.cs index e24ebc235..6c743052c 100644 --- a/lib/PuppeteerSharp/Platform.cs +++ b/lib/PuppeteerSharp/Platform.cs @@ -26,7 +26,7 @@ public enum Platform Linux, /// - /// Linux arm64. + /// Linux ARM64. /// LinuxArm64,