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>
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);
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.
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.
Have you tried the following:
<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
<Costura>
<IncludeAssemblies>
libSkiaSharp
</IncludeAssemblies>
</Costura>
</Weavers>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With