user2481095
user2481095

Reputation: 2106

Fody Costura Does Not Embed SkiaSharp DLL

I created a solution that uses the Costura.Fody nuget package to merge referenced assemblies as embedded resources. I want this so that I can create a single exe for my application. This was working great for a while until I added a reference to SkiaSharp (specifically the nuget packages SkiaSharp and SkiaSharp.Svg). The libSkiaSharp.dll is not embedded and instead built in the startup project folder, and I can't run the program exe on its own unless I keep the dll in the same folder. Is there a way to fix this?

Here's the steps to reproduce this:

1. Create a new WPF project
2. Add the Costura.Fody and Fody nuget packages.
3. Add a file called FodyWeavers.xml with the contents set to this:

<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
  <Costura/>
</Weavers> 
  1. Build and run the exe file in the bin/Debug folder. Notice that program will start up even if you move the exe to a new location.
  2. Add SkiaSharp and SkiaSharp.Svg nuget packages.
  3. get an svg file and add it to your project directory
  4. add the following code to your MainWindow constructor:

    var svg = new SKSvg(); svg.Load("image.svg"); SKCanvas canvas = new SKCanvas(new SKBitmap()); canvas.DrawPicture(svg.Picture);

  5. notice that if you copy the image file and the exe and place in another directory, the exe will not start up. This occurs because it can't find libSkiaSharp.dll.

Upvotes: 4

Views: 3444

Answers (2)

Nekeniehl
Nekeniehl

Reputation: 1691

Have you tried the following:

<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
  <Costura>
    <IncludeAssemblies>
        libSkiaSharp
    </IncludeAssemblies>
  </Costura>
</Weavers>

Upvotes: 1

Joel Lucsy
Joel Lucsy

Reputation: 8706

Create a Costura32 and/or Costura64 folder in your project. Copy libSkiaSharp.dll into the appropriate directory depending on its bitness. Costura will automatically unpack and load native binaries from those directories.

Upvotes: 4

Related Questions