SkiaSharp
SkiaSharp copied to clipboard
[BUG] SkiaSharp not working when deploy Blazor client side application (.NET 7.0) to Azure App Service (Windows) using GitHub Actions (CI/CD Pipeline)
Description
We are using SkiaSharp in Blazor WebAssembly (client side) application. When deploy Blazor client side application (.NET 6.0) to Azure App Service (Windows) using GitHub Actions (CI/CD Pipeline), SkiaSharp works fine without any issue. But when we deploy Blazor client side application (.NET 7.0) to Azure App Service (Windows) using GitHub Actions (CI/CD Pipeline) we are facing libSkiaSharp assembly not found issue.
Code
@page "/skiasharptest"
@inject Microsoft.JSInterop.IJSRuntime JS
@inject HttpClient client
@using SkiaSharp;
@using System.IO
<h2>Hello, world!</h2>
<p>Click the button to draw the text using SkiaSharp.</p>
<button class="btn btn-primary" @onclick="@Create">Create</button>
<p role="status">Status: @msg</p>
@functions {
public string msg = string.Empty;
async void Create()
{
try
{
//Get the text to draw.
String drawText = "Hello";
//Create sKImageInfo object
SKImageInfo sKImageInfo = new SKImageInfo(612, 792);
SKSurface sKSurface = SKSurface.Create(sKImageInfo);
SKCanvas canvas = sKSurface.Canvas;
//Create font.
SKTypeface sKTypeface = SKTypeface.FromFamilyName("Calibri Light", SKFontStyle.Bold);
SKPaint paint = new SKPaint();
paint.TextSize = 11f;
paint.Typeface = sKTypeface;
canvas.DrawText(drawText, 0, 0, paint);
msg = "End";
}
catch (Exception ex)
{
msg = ex.ToString();
msg += ex.Message;
msg += ex.StackTrace.ToString();
}
}
}
Expected Behavior
SkiaSharp should work properly when deploy Blazor client side application (.NET 7.0) to Azure App Service (Windows) using GitHub Actions (CI/CD Pipeline).
Actual Behavior
The following exception is thrown.
System.TypeInitializationException: TypeInitialization_Type, SkiaSharp.SKImageInfo ---> System.DllNotFoundException: libSkiaSharp at SkiaSharp.SKImageInfo..cctor() Exception_EndOfInnerExceptionStack at Blazor_SkiaSharp.Pages.SkiaSharpTest.Create()TypeInitialization_Type, SkiaSharp.SKImageInfo at Blazor_SkiaSharp.Pages.SkiaSharpTest.Create()
Basic Information
- Version with issue: 2.88.3
- IDE: Visual Studio 2022 (17.5.0)
- Platform: ASP.NET Core Blazor (client-side)
- Target Frameworks: .NET 7.0
- Deploy to: Azure App Service (Windows) using GitHub Actions
Reproduction Link
Attached both .NET 7.0 and .NET 6.0 samples along with workflow file, Blazor-GitHub-Actions.zip
Reference videos for how to deploy app to Azure using GitHub Actions (CI/CD Pipeline)
https://www.youtube.com/watch?v=UpWeffxf790 https://www.youtube.com/watch?v=QP0pi7xe24s https://learn.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel
Are you using Docker to build image?
Hi Saibamen,
I’m not using Docker to build an image. I deployed to App Service using GitHub Actions. The GitHub Actions workflow directly builds and deploy the application without containerization.
Regards, Suriya Balamurugan.