Skip to content

Commit 5ad112b

Browse files
authored
Bumped Codeuctivity.HtmlRendere 2.1.46 -> 2.1.62
2 parents 714c289 + 8475371 commit 5ad112b

File tree

10 files changed

+107
-7
lines changed

10 files changed

+107
-7
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ csharp_prefer_static_local_function = true:suggestion
9494
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent
9595

9696
# Code-block preferences
97-
csharp_prefer_braces = true:silent
97+
csharp_prefer_braces = true:warning
9898
csharp_prefer_simple_using_statement = true:suggestion
9999

100100
# Expression-level preferences

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ jobs:
125125
- name: Build
126126
run: dotnet build --configuration Release --no-restore
127127
- name: Publish
128-
run: dotnet publish ./OpenXmlToHtml/OpenXmlToHtmlOpenApi.csproj --configuration Release -o ./Publish
128+
run: dotnet publish ./OpenXmlToHtmlOpenApi/OpenXmlToHtmlOpenApi.csproj --configuration Release -o ./Publish
129129
- uses: azure/webapps-deploy@v2
130130
with:
131131
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}

OpenXmlToHtmlOpenApi/Azure.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Diagnostics;
2+
3+
namespace OpenXmlToHtmlOpenApi
4+
{
5+
/// <summary>
6+
/// Setup dependecies on Azure App Service with Linux plan
7+
/// </summary>
8+
public class Azure
9+
{
10+
/// <summary>
11+
/// Installs every known dependency of chromium used to render html to pdf
12+
/// </summary>
13+
public void SetupChromeiumDependencies()
14+
{
15+
var azureLinuxAppChromeDependencies = "export DEBIAN_FRONTEND=noninteractive && bash -c 'apt update && apt upgrade -y && apt install mc libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libasound2 libnss3 -y >/dev/null 2>&1 & disown'";
16+
17+
var escapedArgs = azureLinuxAppChromeDependencies.Replace("\"", "\\\"");
18+
19+
using var process = new Process
20+
{
21+
StartInfo = new ProcessStartInfo
22+
{
23+
FileName = "/bin/bash",
24+
Arguments = $"-c \"{escapedArgs}\"",
25+
RedirectStandardOutput = true,
26+
UseShellExecute = false,
27+
CreateNoWindow = true,
28+
}
29+
};
30+
31+
process.Start();
32+
process.StandardOutput.ReadToEnd();
33+
process.WaitForExit();
34+
}
35+
}
36+
}

OpenXmlToHtmlOpenApi/OpenXmlToHtmlOpenApi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="Codeuctivity.HtmlRenderer" Version="2.1.46" />
18+
<PackageReference Include="Codeuctivity.HtmlRenderer" Version="2.1.62" />
1919
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" />
2020
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
2121
</ItemGroup>

OpenXmlToHtmlOpenApi/OpenXmlToHtmlOpenApi/OpenXmlToHtmlOpenApi.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OpenXmlToHtmlOpenApi/Program.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.AspNetCore.Hosting;
22
using Microsoft.Extensions.Hosting;
3+
using System;
4+
using System.Runtime.InteropServices;
35

46
namespace OpenXmlToHtmlOpenApi
57
{
@@ -14,9 +16,25 @@ public class Program
1416
/// <param name="args"></param>
1517
public static void Main(string[] args)
1618
{
19+
if (IsRunningOnAzureLinux())
20+
{
21+
new Azure().SetupChromeiumDependencies();
22+
}
23+
1724
CreateHostBuilder(args).Build().Run();
1825
}
1926

27+
private static bool IsRunningOnAzureLinux()
28+
{
29+
var websiteSku = Environment.GetEnvironmentVariable("WEBSITE_SKU");
30+
31+
if (string.IsNullOrEmpty(websiteSku))
32+
{
33+
return false;
34+
}
35+
return RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && websiteSku.Contains("Linux", StringComparison.InvariantCultureIgnoreCase);
36+
}
37+
2038
/// <summary>
2139
/// Called on start
2240
/// </summary>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using OpenXmlToHtmlOpenApi;
2+
using System.Runtime.InteropServices;
3+
using Xunit;
4+
5+
namespace OpenXmlToHtmlOpenApiTests
6+
{
7+
public class AzureTests
8+
{
9+
[SkippableFact]
10+
public void ShoulSetupChromeiumDependencies()
11+
{
12+
Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Linux));
13+
new Azure().SetupChromeiumDependencies();
14+
}
15+
}
16+
}

OpenXmlToHtmlOpenApiTests/OpenXmlConverterControllerIntegrativeTests.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.IO;
55
using System.Net.Http;
6+
using System.Runtime.InteropServices;
67
using System.Threading.Tasks;
78
using Xunit;
89

@@ -17,11 +18,13 @@ public OpenXmlConverterControllerIntegrativeTests(WebApplicationFactory<OpenXmlT
1718
_factory = factory;
1819
}
1920

20-
[Theory]
21+
[SkippableTheory]
2122
[InlineData("/", "text/html; charset=utf-8")]
2223
[InlineData("/swagger/v1/swagger.json", "application/json; charset=utf-8")]
2324
public async Task ShouldAccessEndpointSuccessfull(string route, string contentType)
2425
{
26+
Skip.If(IsRunningOnWsl());
27+
2528
// Arrange
2629
var client = _factory.CreateClient();
2730
var expectedUrl = new Uri($"https://localhost{route}");
@@ -34,9 +37,23 @@ public async Task ShouldAccessEndpointSuccessfull(string route, string contentTy
3437
Assert.Equal(contentType, response.Content.Headers.ContentType.ToString());
3538
}
3639

37-
[Fact]
40+
private static bool IsRunningOnWsl()
41+
{
42+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
43+
{
44+
return false;
45+
}
46+
47+
var version = File.ReadAllText("/proc/version");
48+
var IsWsl = version.Contains("Microsoft", StringComparison.InvariantCultureIgnoreCase);
49+
return IsWsl;
50+
}
51+
52+
[SkippableFact]
3853
public async Task ShouldConvertOpenXmlToHtml()
3954
{
55+
Skip.If(IsRunningOnWsl());
56+
4057
// Arrange
4158
var client = _factory.CreateClient();
4259
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://localhost/OpenXmlConverter");
@@ -57,9 +74,11 @@ public async Task ShouldConvertOpenXmlToHtml()
5774
await AssertHtmlContentAsync(response.Content, "Lorem Ipsum");
5875
}
5976

60-
[Fact]
77+
[SkippableFact]
6178
public async Task ShouldConvertOpenXmlToPdf()
6279
{
80+
Skip.If(IsRunningOnWsl());
81+
6382
// Arrange
6483
var client = _factory.CreateClient();
6584
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://localhost/OpenXmlConverter/ConvertToPdf");

OpenXmlToHtmlOpenApiTests/OpenXmlToHtmlOpenApiTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1919
</PackageReference>
20+
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
2021
</ItemGroup>
2122

2223
<ItemGroup>

OpenXmlToHtmlTests/OpenXmlToHtmlTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Codeuctivity.HtmlRenderer" Version="2.1.46" />
14+
<PackageReference Include="Codeuctivity.HtmlRenderer" Version="2.1.62" />
1515
<PackageReference Include="Codeuctivity.ImageSharpCompare" Version="2.0.61" />
1616
<PackageReference Include="Moq" Version="4.18.1" />
1717
<PackageReference Include="PdfSharp.netstandard" Version="1.3.2" />

0 commit comments

Comments
 (0)