Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/PuppeteerSharp/BrowserData/Chrome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
};
Expand Down Expand Up @@ -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
{
Expand All @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions lib/PuppeteerSharp/BrowserData/ChromeHeadlessShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions lib/PuppeteerSharp/BrowserData/Chromium.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Copy link
Preview

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] There's repeated grouping of Platform.Linux and Platform.LinuxArm64; consider extracting a helper (e.g., IsLinuxPlatform) or shared method to reduce duplication across switch statements.

Suggested change
Platform.Linux or Platform.LinuxArm64 => Path.Combine("chrome-linux", "chrome"),
_ when IsLinuxPlatform(platform) => Path.Combine("chrome-linux", "chrome"),

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah

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.
Expand All @@ -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",
Expand Down
10 changes: 6 additions & 4 deletions lib/PuppeteerSharp/BrowserData/Firefox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
};
Expand All @@ -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)),
};
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 5 additions & 1 deletion lib/PuppeteerSharp/BrowserFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,16 @@

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return RuntimeInformation.OSArchitecture == Architecture.X64 ? Platform.Win64 : Platform.Win32;
return RuntimeInformation.OSArchitecture == Architecture.X64 ||
Copy link
Preview

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider introducing a dedicated Platform.WinArm64 enum or a helper to explicitly represent Windows ARM64 rather than mapping it to Win64 for clarity in ARM support.

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not yet

(RuntimeInformation.OSArchitecture == Architecture.Arm64 && 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;
Expand All @@ -174,7 +178,7 @@

if (!assemblyDirectory.Exists || !File.Exists(Path.Combine(assemblyDirectory.FullName, assemblyName)))
{
var assemblyLocation = assembly.Location;

Check warning on line 181 in lib/PuppeteerSharp/BrowserFetcher.cs

View workflow job for this annotation

GitHub Actions / Demo Project (windows-2022)

PuppeteerSharp.BrowserFetcher.GetBrowsersLocation(): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.

if (string.IsNullOrEmpty(assemblyLocation))
{
Expand Down
5 changes: 5 additions & 0 deletions lib/PuppeteerSharp/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public enum Platform
/// </summary>
Linux,

/// <summary>
/// Linux ARM64.
/// </summary>
LinuxArm64,

/// <summary>
/// Win32.
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions lib/PuppeteerSharp/PuppeteerSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<Description>Headless Browser .NET API</Description>
<PackageId>PuppeteerSharp</PackageId>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageVersion>20.2.1</PackageVersion>
<ReleaseVersion>20.2.1</ReleaseVersion>
<AssemblyVersion>20.2.1</AssemblyVersion>
<FileVersion>20.2.1</FileVersion>
<PackageVersion>20.2.2</PackageVersion>
<ReleaseVersion>20.2.2</ReleaseVersion>
<AssemblyVersion>20.2.2</AssemblyVersion>
<FileVersion>20.2.2</FileVersion>
<SynchReleaseVersion>false</SynchReleaseVersion>
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
<DebugType>embedded</DebugType>
Expand Down
Loading