mono/SkiaSharp

libSkiaSharp.so doesn't get copied automatically to the bin/{Debug|Release}/ folder from its SkiaSharp.NativeAssets.Linux nuget folder

knocte opened this issue · 11 comments

It seems that the documentation in https://github.com/mono/SkiaSharp/wiki/SkiaSharp-Native-Assets-for-Linux is incomplete, because I have noticed that in my build, after adding the nuget package SkiaSharp.NativeAssets.Linux and building the project, the .so file doesn't actually get copied to the proper location.

How do you guys do it? A PostBuild msbuild task to copy the file? Thanks

I have the same issue too.
Centos7 x64
asp.net core 2.2
docker

System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies.

Anyone had worked on it?

Thanks bro.I have solved it.You code is very useful,it‘s inspiring.
Add this in Dockerfile

RUN apt-get update;apt-get install libfontconfig1 -y;

and copy

libSkiaSharp.so

into root of project.

With Linux, I think it will copy the .so file only when you publish.

With Linux, I think it will copy the .so file only when you publish.

Sorry, what do you mean with "publish" exactly?

Maybe I should not assume... Are you using .NET Core or mono?

If you are using .NET Core, then a dotnet publish should copy everything you need. Just make sure to keep the *.deps.json file with the .dll. If you don't publish, make sure you copy the *.runtimeconfig.dev.json and *.deps.json files as they contain the bits needed for dotnet core to find the .so file in your NuGet cache.

There is also a very specific publish which only copies the specific files: dotnet publish -r linux-x64 that will create a special folder with EVERYTHING that is needed to run - no additional files outside the new folder are needed. It creates an executable binary that you can run without dotnet installed.

But... If you are using mono, then things are a bit different. There is a bug :)
I think I have been misunderstanding a whole bunch of issues, so apologies for that. But, I hope to get a fix out soon.

The current PR for this is #886

A workaround would be to add this to the bottom of the .csproj:

<Target Name="AfterBuild">
  <Copy SourceFiles="$(NuGetPackageRoot)skiasharp.nativeassets.linux\1.68.0\runtimes\linux-x64\native\libSkiaSharp.so"
        DestinationFiles="$(TargetDir)libSkiaSharp.so" />
</Target>

But... If you are using mono, then things are a bit different. There is a bug :)

Yes, sorry, I should have mentioned I was using mono, in the original report.

The current PR for this is #886

Great to see an official fix for this!

A workaround would be to add this to the bottom of the .csproj:

Exactly the workaround I was using, which I also pointed out in #794 (comment). BTW, FYI my workaround is a bit more correct than yours because yours only works in case-insensitive filesystems ;)

I just merged #794, so as soon as the build is complete I will release to the preview feed: https://nugetized.blob.core.windows.net/skiasharp-eap/index.json

@knocte the fix should be up on the preview feed. Version 1.68.1-rc.131

@knocte the fix should be up on the preview feed. Version 1.68.1-rc.131

Thanks for the heads up, but for me consuming something from anything other than the official nuget feed is a bit convoluted. When will it hit nuget.org? Will 1.68.1 be the first version that contains this fix?

I am hoping that the first public preview will hit the nuget.org feed soon, can't say exactly as I am waiting on feedback from the consumers of the preview feed. Probably in a week or so.

But, to use the preview feed, you can just add a nuget.config to the project or solution folder and then nuget will restore from the feed as well:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="skiasharp-eap" value="https://nugetized.blob.core.windows.net/skiasharp-eap/index.json" />
  </packageSources>
</configuration>