From 4168590ab0f6e31729b74df13906dcf94d80c5ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Mon, 12 Jan 2026 15:58:28 -0300 Subject: [PATCH 1/3] Migrate to .NET 10 --- .../PushNugetPackageToIntNugetOrg.yml | 4 +- .../workflows/PushNugetPackageToNugetOrg.yml | 4 +- .github/workflows/demo.yml | 6 +- .github/workflows/dotnet.yml | 2 +- .github/workflows/on-push-do-docs.yml | 2 +- .github/workflows/publish-docs.yml | 2 +- .../PuppeteerSharpPdfDemo-Local.csproj | 4 +- .../PuppeteerSharp.DevicesFetcher.csproj | 2 +- .../PuppeteerSharp.Nunit.csproj | 2 +- .../PuppeteerSharp.TestServer.csproj | 2 +- lib/PuppeteerSharp.TestServer/SimpleServer.cs | 106 +++++++++--------- .../PuppeteerSharp.Tests.DumpIO.csproj | 2 +- ...eerSharp.Tests.SingleFileDeployment.csproj | 2 +- .../PuppeteerSharp.Tests.csproj | 4 +- .../PuppeteerSharp.Tooling.csproj | 2 +- lib/PuppeteerSharp/PuppeteerSharp.csproj | 4 +- 16 files changed, 75 insertions(+), 75 deletions(-) diff --git a/.github/workflows/PushNugetPackageToIntNugetOrg.yml b/.github/workflows/PushNugetPackageToIntNugetOrg.yml index bbe5ec866..07f521bf1 100644 --- a/.github/workflows/PushNugetPackageToIntNugetOrg.yml +++ b/.github/workflows/PushNugetPackageToIntNugetOrg.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: env: - DOTNET_VERSION: '8.0.x' # The .NET SDK version to use + DOTNET_VERSION: '10.0.x' # The .NET SDK version to use jobs: PushToIntNugetOrg: @@ -14,7 +14,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 10.0.x - name: Install dependencies run: | dotnet restore lib/PuppeteerSharp.sln diff --git a/.github/workflows/PushNugetPackageToNugetOrg.yml b/.github/workflows/PushNugetPackageToNugetOrg.yml index d326f725f..c1d7e3e37 100644 --- a/.github/workflows/PushNugetPackageToNugetOrg.yml +++ b/.github/workflows/PushNugetPackageToNugetOrg.yml @@ -7,7 +7,7 @@ on: - v* env: - DOTNET_VERSION: '8.0.x' # The .NET SDK version to use + DOTNET_VERSION: '10.0.x' # The .NET SDK version to use jobs: PushToNugetOrg: @@ -17,7 +17,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 10.0.x - name: Install dependencies run: | dotnet restore lib/PuppeteerSharp.sln diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 1aa1ac79e..69bc09669 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -20,7 +20,7 @@ jobs: matrix: os: [windows-2022, macos-latest] env: - DOTNET_VERSION: '8.0.x' # The .NET SDK version to use + DOTNET_VERSION: '10.0.x' # The .NET SDK version to use steps: - uses: actions/checkout@v2 @@ -37,12 +37,12 @@ jobs: - name: Run on .NET working-directory: ./demos/PuppeteerSharpPdfDemo run: | - dotnet run --project PuppeteerSharpPdfDemo-Local.csproj auto-exit -f net8.0 + dotnet run --project PuppeteerSharpPdfDemo-Local.csproj auto-exit -f net10.0 - name: Run with AOT if: matrix.os == 'windows-2022' working-directory: ./demos/PuppeteerSharpPdfDemo run: | - dotnet publish PuppeteerSharpPdfDemo-Local.csproj -r win-x64 -o build -f net8.0 + dotnet publish PuppeteerSharpPdfDemo-Local.csproj -r win-x64 -o build -f net10.0 build/PuppeteerSharpPdfDemo-Local.exe auto-exit - name: Run on .NET Framework if: matrix.os == 'windows-2022' diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 312181cd6..8141b8975 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -15,7 +15,7 @@ on: - '**.runsettings' env: - DOTNET_VERSION: '8.0.x' # The .NET SDK version to use + DOTNET_VERSION: '10.0.x' # The .NET SDK version to use jobs: build: diff --git a/.github/workflows/on-push-do-docs.yml b/.github/workflows/on-push-do-docs.yml index 26843e88f..0811bc572 100644 --- a/.github/workflows/on-push-do-docs.yml +++ b/.github/workflows/on-push-do-docs.yml @@ -9,7 +9,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 10.0.x - name: Run MarkdownSnippets run: | dotnet tool install --global MarkdownSnippets.Tool diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 7c804c209..bec09d5d8 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -17,7 +17,7 @@ jobs: name: Publish docs runs-on: windows-latest env: - DOTNET_VERSION: '8.0.x' # The .NET SDK version to use + DOTNET_VERSION: '10.0.x' # The .NET SDK version to use steps: - uses: actions/checkout@v4 diff --git a/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo-Local.csproj b/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo-Local.csproj index 7c54d4290..7de8bebad 100644 --- a/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo-Local.csproj +++ b/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo-Local.csproj @@ -1,10 +1,10 @@ Exe - net8.0;net471 + net10.0;net471 12 - + true diff --git a/lib/PuppeteerSharp.DevicesFetcher/PuppeteerSharp.DevicesFetcher.csproj b/lib/PuppeteerSharp.DevicesFetcher/PuppeteerSharp.DevicesFetcher.csproj index 83247b553..4cd7fa3f4 100644 --- a/lib/PuppeteerSharp.DevicesFetcher/PuppeteerSharp.DevicesFetcher.csproj +++ b/lib/PuppeteerSharp.DevicesFetcher/PuppeteerSharp.DevicesFetcher.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 12 diff --git a/lib/PuppeteerSharp.Nunit/PuppeteerSharp.Nunit.csproj b/lib/PuppeteerSharp.Nunit/PuppeteerSharp.Nunit.csproj index 9a2301b29..e8c758eee 100644 --- a/lib/PuppeteerSharp.Nunit/PuppeteerSharp.Nunit.csproj +++ b/lib/PuppeteerSharp.Nunit/PuppeteerSharp.Nunit.csproj @@ -1,7 +1,7 @@ - net8.0 + net10.0 12 diff --git a/lib/PuppeteerSharp.TestServer/PuppeteerSharp.TestServer.csproj b/lib/PuppeteerSharp.TestServer/PuppeteerSharp.TestServer.csproj index a61dac2dd..45808b0fc 100644 --- a/lib/PuppeteerSharp.TestServer/PuppeteerSharp.TestServer.csproj +++ b/lib/PuppeteerSharp.TestServer/PuppeteerSharp.TestServer.csproj @@ -1,6 +1,6 @@ - net8.0 + net10.0 Library 12 diff --git a/lib/PuppeteerSharp.TestServer/SimpleServer.cs b/lib/PuppeteerSharp.TestServer/SimpleServer.cs index 2d39a8e79..72eae2458 100644 --- a/lib/PuppeteerSharp.TestServer/SimpleServer.cs +++ b/lib/PuppeteerSharp.TestServer/SimpleServer.cs @@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; namespace PuppeteerSharp.TestServer { @@ -17,7 +17,7 @@ public class SimpleServer private readonly IDictionary _routes; private readonly IDictionary _auths; private readonly IDictionary _csp; - private readonly IWebHost _webHost; + private readonly WebApplication _webHost; internal IList GzipRoutes { get; } public static SimpleServer Create(int port, string contentRoot) => new SimpleServer(port, contentRoot, isHttps: false); @@ -31,61 +31,63 @@ private SimpleServer(int port, string contentRoot, bool isHttps) _csp = new ConcurrentDictionary(); GzipRoutes = new List(); - _webHost = new WebHostBuilder() - .ConfigureAppConfiguration((context, builder) => builder - .SetBasePath(context.HostingEnvironment.ContentRootPath) - .AddEnvironmentVariables() - ) - .Configure(app => app.Use((context, next) => - { - if (_auths.TryGetValue(context.Request.Path, out var auth) && !Authenticate(auth.username, auth.password, context)) - { - context.Response.Headers.Add("WWW-Authenticate", "Basic realm=\"Secure Area\""); - context.Response.StatusCode = StatusCodes.Status401Unauthorized; - return context.Response.WriteAsync("HTTP Error 401 Unauthorized: Access is denied"); - } - if (_requestSubscribers.TryGetValue(context.Request.Path, out var subscriber)) - { - subscriber(context.Request); - } - if (_routes.TryGetValue(context.Request.Path + context.Request.QueryString, out var handler)) - { - return handler(context); - } - - return next(); - }) - .UseMiddleware(this) - .UseStaticFiles(new StaticFileOptions - { - OnPrepareResponse = fileResponseContext => - { - if (_csp.TryGetValue(fileResponseContext.Context.Request.Path, out var csp)) - { - fileResponseContext.Context.Response.Headers["Content-Security-Policy"] = csp; - } - - if (fileResponseContext.Context.Request.Path.Value != null && !fileResponseContext.Context.Request.Path.Value.StartsWith("/cached/")) - { - fileResponseContext.Context.Response.Headers["Cache-Control"] = "no-cache, no-store"; - fileResponseContext.Context.Response.Headers["Expires"] = "-1"; - } - } - })) - .UseKestrel(options => + var builder = WebApplication.CreateBuilder(new WebApplicationOptions + { + ContentRootPath = contentRoot + }); + + builder.WebHost.UseKestrel(options => + { + options.ConfigureEndpointDefaults(lo => lo.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1); + if (isHttps) { - options.ConfigureEndpointDefaults(lo => lo.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1); - if (isHttps) + options.Listen(IPAddress.Loopback, port, listenOptions => listenOptions.UseHttps("testCert.cer")); + } + else + { + options.Listen(IPAddress.Loopback, port); + } + }); + + _webHost = builder.Build(); + + _webHost.Use((context, next) => + { + if (_auths.TryGetValue(context.Request.Path, out var auth) && !Authenticate(auth.username, auth.password, context)) + { + context.Response.Headers.Append("WWW-Authenticate", "Basic realm=\"Secure Area\""); + context.Response.StatusCode = StatusCodes.Status401Unauthorized; + return context.Response.WriteAsync("HTTP Error 401 Unauthorized: Access is denied"); + } + if (_requestSubscribers.TryGetValue(context.Request.Path, out var subscriber)) + { + subscriber(context.Request); + } + if (_routes.TryGetValue(context.Request.Path + context.Request.QueryString, out var handler)) + { + return handler(context); + } + + return next(); + }); + + _webHost.UseMiddleware(this); + _webHost.UseStaticFiles(new StaticFileOptions + { + OnPrepareResponse = fileResponseContext => + { + if (_csp.TryGetValue(fileResponseContext.Context.Request.Path, out var csp)) { - options.Listen(IPAddress.Loopback, port, listenOptions => listenOptions.UseHttps("testCert.cer")); + fileResponseContext.Context.Response.Headers["Content-Security-Policy"] = csp; } - else + + if (fileResponseContext.Context.Request.Path.Value != null && !fileResponseContext.Context.Request.Path.Value.StartsWith("/cached/")) { - options.Listen(IPAddress.Loopback, port); + fileResponseContext.Context.Response.Headers["Cache-Control"] = "no-cache, no-store"; + fileResponseContext.Context.Response.Headers["Expires"] = "-1"; } - }) - .UseContentRoot(contentRoot) - .Build(); + } + }); } public void SetAuth(string path, string username, string password) => _auths.Add(path, (username, password)); diff --git a/lib/PuppeteerSharp.Tests.DumpIO/PuppeteerSharp.Tests.DumpIO.csproj b/lib/PuppeteerSharp.Tests.DumpIO/PuppeteerSharp.Tests.DumpIO.csproj index 6d86a63ac..f15cc34d1 100644 --- a/lib/PuppeteerSharp.Tests.DumpIO/PuppeteerSharp.Tests.DumpIO.csproj +++ b/lib/PuppeteerSharp.Tests.DumpIO/PuppeteerSharp.Tests.DumpIO.csproj @@ -1,7 +1,7 @@ Exe - net8.0 + net10.0 12 diff --git a/lib/PuppeteerSharp.Tests.SingleFileDeployment/PuppeteerSharp.Tests.SingleFileDeployment.csproj b/lib/PuppeteerSharp.Tests.SingleFileDeployment/PuppeteerSharp.Tests.SingleFileDeployment.csproj index c957ecb60..188b5cb4b 100644 --- a/lib/PuppeteerSharp.Tests.SingleFileDeployment/PuppeteerSharp.Tests.SingleFileDeployment.csproj +++ b/lib/PuppeteerSharp.Tests.SingleFileDeployment/PuppeteerSharp.Tests.SingleFileDeployment.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 enable enable 12 diff --git a/lib/PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj b/lib/PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj index 5c7974a66..da742f50c 100644 --- a/lib/PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj +++ b/lib/PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj @@ -1,13 +1,12 @@ - net8.0 + net10.0 true 12 - @@ -17,7 +16,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/lib/PuppeteerSharp.Tooling/PuppeteerSharp.Tooling.csproj b/lib/PuppeteerSharp.Tooling/PuppeteerSharp.Tooling.csproj index fe03566bb..f46d2d15c 100644 --- a/lib/PuppeteerSharp.Tooling/PuppeteerSharp.Tooling.csproj +++ b/lib/PuppeteerSharp.Tooling/PuppeteerSharp.Tooling.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 true true 12 diff --git a/lib/PuppeteerSharp/PuppeteerSharp.csproj b/lib/PuppeteerSharp/PuppeteerSharp.csproj index b79f065eb..6d29fca62 100644 --- a/lib/PuppeteerSharp/PuppeteerSharp.csproj +++ b/lib/PuppeteerSharp/PuppeteerSharp.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net8.0 + netstandard2.0;net10.0 Darío Kondratiuk Darío Kondratiuk https://github.com/hardkoded/puppeteer-sharp @@ -25,7 +25,7 @@ true true 12 - 8.0-Recommended + 10.0-Recommended README.md From e395049ceb4bcb31a89bbea9e9fbf9f004c4fb50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Mon, 12 Jan 2026 16:23:31 -0300 Subject: [PATCH 2/3] fix net10 --- lib/PuppeteerSharp/BrowserFetcher.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/PuppeteerSharp/BrowserFetcher.cs b/lib/PuppeteerSharp/BrowserFetcher.cs index 55c1d0279..4b316d6c8 100644 --- a/lib/PuppeteerSharp/BrowserFetcher.cs +++ b/lib/PuppeteerSharp/BrowserFetcher.cs @@ -178,7 +178,9 @@ internal static string GetBrowsersLocation() if (!assemblyDirectory.Exists || !File.Exists(Path.Combine(assemblyDirectory.FullName, assemblyName))) { +#pragma warning disable IL3000 // Avoid accessing Assembly file path when publishing as a single file - fallback handling exists below var assemblyLocation = assembly.Location; +#pragma warning restore IL3000 if (string.IsNullOrEmpty(assemblyLocation)) { From 5737511e94ec8932d16b34e451cb16a99ca82393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Mon, 12 Jan 2026 19:56:14 -0300 Subject: [PATCH 3/3] fix build --- .../PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo-Local.csproj | 2 ++ lib/PuppeteerSharp/PuppeteerSharp.csproj | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo-Local.csproj b/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo-Local.csproj index 7de8bebad..fbc46f9a6 100644 --- a/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo-Local.csproj +++ b/demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo-Local.csproj @@ -6,6 +6,8 @@ true + + $(NoWarn);IL3000 diff --git a/lib/PuppeteerSharp/PuppeteerSharp.csproj b/lib/PuppeteerSharp/PuppeteerSharp.csproj index 6d29fca62..1925f0154 100644 --- a/lib/PuppeteerSharp/PuppeteerSharp.csproj +++ b/lib/PuppeteerSharp/PuppeteerSharp.csproj @@ -28,6 +28,10 @@ 10.0-Recommended README.md + + + $(NoWarn);IL3000 +