Skip to content

Commit 838380c

Browse files
authored
Bump PuppeteerSharp from 8.0.0 to 9.0.1
2 parents 7d587ae + 2c85176 commit 838380c

File tree

11 files changed

+40
-34
lines changed

11 files changed

+40
-34
lines changed

.github/workflows/dotnet.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: .NET build and test
22
env:
3-
CURRENT_VERSION: 2.1.${{ github.run_number }}
3+
CURRENT_VERSION: 2.2.${{ github.run_number }}
44
LAST_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
55

66
on:
@@ -58,7 +58,7 @@ jobs:
5858
- name: Build
5959
run: dotnet build --configuration Release --no-restore
6060
- name: Publish FolderProfileWindows
61-
run: dotnet publish ./Codeuctivity.HtmlRendererCli --configuration Release -f net7.0 -p:PublishProfile=FolderProfileWindows
61+
run: dotnet publish ./Codeuctivity.HtmlRendererCli --configuration Release -f net6.0 -p:PublishProfile=FolderProfileWindows
6262
- name: Publish FolderProfilePortable
6363
run: dotnet publish ./Codeuctivity.HtmlRendererCli --configuration Release -f net6.0 -p:PublishProfile=FolderProfilePortable
6464
- name: Zip FolderProfilePortable

Codeuctivity.HtmlRenderer/Codeuctivity.HtmlRenderer.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939

4040
<ItemGroup>
4141
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
42-
<PackageReference Include="PuppeteerSharp" Version="8.0.0" />
43-
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.50.0.58025">
42+
<PackageReference Include="PuppeteerSharp" Version="9.0.1" />
43+
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.51.0.59060">
4444
<PrivateAssets>all</PrivateAssets>
4545
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4646
</PackageReference>

Codeuctivity.HtmlRenderer/Renderer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public Renderer(LaunchOptions? launchOptions = null)
5050
/// <summary>
5151
/// Browser fetcher - used to get chromium bins
5252
/// </summary>
53-
public BrowserFetcher BrowserFetcher { get; private set; } = default!;
53+
public BrowserFetcher BrowserFetcher { get; private set; }
5454

5555
private LaunchOptions LaunchOptions { get; }
5656

@@ -91,8 +91,8 @@ private async Task<Renderer> InitializeAsync(BrowserFetcher browserFetcher)
9191
{
9292
BrowserFetcher = browserFetcher;
9393
BrowserFetcher.DownloadProgressChanged += DownloadProgressChanged;
94-
95-
_ = await BrowserFetcher.DownloadAsync(BrowserFetcher.DefaultChromiumRevision ?? string.Empty).ConfigureAwait(false);
94+
var revisionInfo = await BrowserFetcher.DownloadAsync(BrowserFetcher.DefaultChromiumRevision ?? string.Empty).ConfigureAwait(false);
95+
LaunchOptions.ExecutablePath = revisionInfo.ExecutablePath;
9696
Browser = await Puppeteer.LaunchAsync(LaunchOptions).ConfigureAwait(false);
9797
return this;
9898
}

Codeuctivity.HtmlRendererCli/Codeuctivity.HtmlRendererCli.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
5+
<TargetFrameworks>net6.0</TargetFrameworks>
66
<EnableNETAnalyzers>true</EnableNETAnalyzers>
77
<RootNamespace>Codeuctivity.HtmlRendererCli</RootNamespace>
8+
<DebugSymbols>true</DebugSymbols>
9+
<DebugType>embedded</DebugType>
810
</PropertyGroup>
911

1012
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

Codeuctivity.HtmlRendererCli/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ public static async Task<int> Main(string[] args)
3737
}
3838

3939
Console.WriteLine($"Converting {inputPathDocx} to {outputPathHtml} using PuppeteerSharp.Renderer {Version}");
40-
var browserFetcher = new BrowserFetcher();
40+
BrowserFetcherOptions options = new BrowserFetcherOptions();
41+
options.Path = Path.GetTempPath();
42+
var browserFetcher = new BrowserFetcher(options);
4143
Console.WriteLine($"Fetching chromium from web, to {browserFetcher.DownloadsFolder} .... ");
4244
browserFetcher.DownloadProgressChanged += BrowserFetcher_DownloadProgressChanged;
4345
await using var chromiumRenderer = await Renderer.CreateAsync(browserFetcher, string.Empty);

Codeuctivity.HtmlRendererCli/Properties/PublishProfiles/FolderProfileWindows.pubxml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
66
<PropertyGroup>
77
<Configuration>Release</Configuration>
88
<Platform>Any CPU</Platform>
9-
<PublishDir>bin\Release\net7.0\publish\FolderProfileWindows\</PublishDir>
9+
<PublishDir>bin\Release\net6.0\publish\FolderProfileWindows\</PublishDir>
1010
<PublishProtocol>FileSystem</PublishProtocol>
11-
<TargetFramework>net7.0</TargetFramework>
11+
<TargetFramework>net6.0</TargetFramework>
1212
<SelfContained>true</SelfContained>
1313
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
1414
<PublishSingleFile>true</PublishSingleFile>
1515
<PublishReadyToRun>false</PublishReadyToRun>
16-
<PublishTrimmed>false</PublishTrimmed>
16+
<PublishTrimmed>true</PublishTrimmed>
1717
</PropertyGroup>
1818
</Project>

Codeuctivity.HtmlRendererCliTests/Codeuctivity.HtmlRendererCliTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
11-
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.50.0.58025">
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
11+
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.51.0.59060">
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
<PrivateAssets>all</PrivateAssets>
1414
</PackageReference>

Codeuctivity.HtmlRendererCliTests/RendererCliTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public void PublishedSelfContainedBinaryShouldWork()
5656
};
5757

5858
process.Start();
59+
var outputResult = GetStreamOutput(process.StandardOutput);
60+
var errorResult = GetStreamOutput(process.StandardError);
5961
var isExited = process.WaitForExit(80000);
6062

6163
if (!isExited)
@@ -66,13 +68,13 @@ public void PublishedSelfContainedBinaryShouldWork()
6668

6769
Assert.True(isExited);
6870

69-
Assert.True(File.Exists(actualFilePath));
71+
Assert.True(File.Exists(actualFilePath), $"StdOut: {outputResult}\nStdErr: {errorResult}\n");
7072
}
7173

7274
private static string DotnetPublishFolderProfileWindows(string projectName)
7375
{
7476
var absolutePath = Path.GetFullPath("../../../../" + projectName);
75-
var expectedBinaryPath = Path.Combine(absolutePath, $"bin/Release/net7.0/publish/FolderProfileWindows/{projectName}.exe");
77+
var expectedBinaryPath = Path.Combine(absolutePath, $"bin/Release/net6.0/publish/FolderProfileWindows/{projectName}.exe");
7678

7779
if (File.Exists(expectedBinaryPath))
7880
{
@@ -84,7 +86,7 @@ private static string DotnetPublishFolderProfileWindows(string projectName)
8486
StartInfo = new ProcessStartInfo
8587
{
8688
FileName = "dotnet",
87-
Arguments = $"publish {absolutePath} --configuration Release -f net7.0 -p:PublishProfile=FolderProfileWindows",
89+
Arguments = $"publish {absolutePath} --configuration Release -f net6.0 -p:PublishProfile=FolderProfileWindows",
8890
RedirectStandardOutput = true,
8991
RedirectStandardError = true,
9092
UseShellExecute = false,

Codeuctivity.HtmlRendererTests/Codeuctivity.HtmlRendererTests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
<ItemGroup>
1919
<PackageReference Include="Codeuctivity.ImageSharpCompare" Version="2.0.76" />
20-
<PackageReference Include="Codeuctivity.PdfjsSharp" Version="1.2.70" />
21-
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.50.0.58025">
20+
<PackageReference Include="Codeuctivity.PdfjsSharp" Version="1.2.95" />
21+
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.51.0.59060">
2222
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2323
<PrivateAssets>all</PrivateAssets>
2424
</PackageReference>
25-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
25+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
2626
<PackageReference Include="xunit" Version="2.4.2" />
2727
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
2828
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

Codeuctivity.HtmlRendererTests/RendererTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,21 @@ public async Task ShouldConvertHtmlToPdf(string testFileName)
4242

4343
var actualImagePathDirectory = Path.Combine(Path.GetTempPath(), testFileName);
4444

45-
if (!IsRunningOnWslOrAzureOrMacos())
45+
if (!IsRunningOnAzureOrMacos())
4646
{
4747
var actualImages = await Rasterize.ConvertToPngAsync(actualFilePath, actualImagePathDirectory);
4848
Assert.Single(actualImages);
49-
DocumentAsserter.AssertImageIsEqual(actualImages.Single(), expectReferenceFilePath, 2000);
49+
// File.Copy(actualImages.Single(), expectReferenceFilePath, true);
50+
DocumentAsserter.AssertImageIsEqual(actualImages.Single(), expectReferenceFilePath, 8000);
5051
}
5152
File.Delete(actualFilePath);
5253
}
5354
await ChromiumProcessDisposedAsserter.AssertNoChromiumProcessIsRunning();
5455
}
5556

5657
[Theory]
57-
[InlineData("BasicTextFormatedInlineBackground.html", false, 6000)]
58-
[InlineData("BasicTextFormatedInlineBackground.html", true, 6000)]
58+
[InlineData("BasicTextFormatedInlineBackground.html", false, 9000)]
59+
[InlineData("BasicTextFormatedInlineBackground.html", true, 9000)]
5960
public async Task ShouldConvertHtmlToPdfWithOptions(string testFileName, bool printBackground, int allowedPixelDiff)
6061
{
6162
var sourceHtmlFilePath = $"../../../TestInput/{testFileName}";
@@ -73,7 +74,7 @@ public async Task ShouldConvertHtmlToPdfWithOptions(string testFileName, bool pr
7374

7475
var actualImagePathDirectory = Path.Combine(Path.GetTempPath(), testFileName);
7576

76-
if (!IsRunningOnWslOrAzureOrMacos())
77+
if (!IsRunningOnAzureOrMacos())
7778
{
7879
try
7980
{
@@ -93,7 +94,7 @@ public async Task ShouldConvertHtmlToPdfWithOptions(string testFileName, bool pr
9394
await ChromiumProcessDisposedAsserter.AssertNoChromiumProcessIsRunning();
9495
}
9596

96-
private static bool IsRunningOnWslOrAzureOrMacos()
97+
private static bool IsRunningOnAzureOrMacos()
9798
{
9899
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))
99100
{
@@ -107,9 +108,8 @@ private static bool IsRunningOnWslOrAzureOrMacos()
107108

108109
var version = File.ReadAllText("/proc/version");
109110
var IsAzure = version.IndexOf("azure", StringComparison.OrdinalIgnoreCase) >= 0;
110-
var IsWsl = version.IndexOf("Microsoft", StringComparison.OrdinalIgnoreCase) >= 0;
111111

112-
return IsWsl || IsAzure;
112+
return IsAzure;
113113
}
114114

115115
[Theory]
@@ -137,7 +137,7 @@ public async Task ShouldConvertHtmlToPng(string testFileName)
137137
}
138138

139139
[Theory]
140-
[InlineData("BasicTextFormatedInlineBackground.html", false, 11000)]
140+
[InlineData("BasicTextFormatedInlineBackground.html", false, 15000)]
141141
[InlineData("BasicTextFormatedInlineBackground.html", true, 9500)]
142142
public async Task ShouldConvertHtmlToPngScreenshotOptions(string testFileName, bool omitBackground, int allowedPixelDiff)
143143
{
@@ -158,7 +158,7 @@ public async Task ShouldConvertHtmlToPngScreenshotOptions(string testFileName, b
158158
};
159159

160160
await chromiumRenderer.ConvertHtmlToPng(sourceHtmlFilePath, actualFilePath, screenshotOptions);
161-
// File.Copy(actualFilePath, expectReferenceFilePath);
161+
// File.Copy(actualFilePath, expectReferenceFilePath, true);
162162
DocumentAsserter.AssertImageIsEqual(actualFilePath, expectReferenceFilePath, allowedPixelDiff);
163163
}
164164

0 commit comments

Comments
 (0)