Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions .github/workflows/PushNugetPackageToIntNugetOrg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/PushNugetPackageToNugetOrg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on-push-do-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net8.0;net471</TargetFrameworks>
<TargetFrameworks>net10.0;net471</TargetFrameworks>
<LangVersion>12</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PropertyGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PublishAot>true</PublishAot>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>12</LangVersion>
</PropertyGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion lib/PuppeteerSharp.Nunit/PuppeteerSharp.Nunit.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>12</LangVersion>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Library</OutputType>
<LangVersion>12</LangVersion>
</PropertyGroup>
Expand Down
106 changes: 54 additions & 52 deletions lib/PuppeteerSharp.TestServer/SimpleServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -17,7 +17,7 @@ public class SimpleServer
private readonly IDictionary<string, RequestDelegate> _routes;
private readonly IDictionary<string, (string username, string password)> _auths;
private readonly IDictionary<string, string> _csp;
private readonly IWebHost _webHost;
private readonly WebApplication _webHost;

internal IList<string> GzipRoutes { get; }
public static SimpleServer Create(int port, string contentRoot) => new SimpleServer(port, contentRoot, isHttps: false);
Expand All @@ -31,61 +31,63 @@ private SimpleServer(int port, string contentRoot, bool isHttps)
_csp = new ConcurrentDictionary<string, string>();
GzipRoutes = new List<string>();

_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<SimpleCompressionMiddleware>(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<SimpleCompressionMiddleware>(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));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>12</LangVersion>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>12</LangVersion>
Expand Down
4 changes: 1 addition & 3 deletions lib/PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<IsTestProject>true</IsTestProject>
<LangVersion>12</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MarkdownSnippets.MsBuild" Version="27.0.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
Expand All @@ -17,7 +16,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.11" />
<PackageReference Include="Microsoft.AspNetCore.Connections.Abstractions" Version="2.2.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion lib/PuppeteerSharp.Tooling/PuppeteerSharp.Tooling.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<IsTool>true</IsTool>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>12</LangVersion>
Expand Down
4 changes: 2 additions & 2 deletions lib/PuppeteerSharp/PuppeteerSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net10.0</TargetFrameworks>
<Authors>Darío Kondratiuk</Authors>
<Owners>Darío Kondratiuk</Owners>
<PackageProjectUrl>https://github.com/hardkoded/puppeteer-sharp</PackageProjectUrl>
Expand All @@ -25,7 +25,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<LangVersion>12</LangVersion>
<AnalysisLevel>8.0-Recommended</AnalysisLevel>
<AnalysisLevel>10.0-Recommended</AnalysisLevel>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<Import Project="../Common/CommonProps.props" />
Expand Down
Loading