costura.fody for a dll that references another dll

I have a small exe I've written that uses LibGit2Sharp and am trying to use Costura.Fody to embed everything so I only have a single exe to distribute (actually, there are two config files as well, but that's ok).

The problem seems to be that LibGet2Sharp.dll has a fairly firm reference to git2-1196807.dll, and I can't seem to figure out how to embed the latter in the way the former can use. I've tried several things, but I think my best attempt is:

all of these .dll's are copied from the solution's packages folder and set to Build Action = Embedded Resource and Copy to Output Directory = Do Not Copy.

<img src=https://www.e-learn.cn/content/wangluowenzhang/"https://i.stack.imgur.com/p1X4c.png" alt="add .dll's to project explicitely">

The LibGit2Sharp reference is set to Copy Local = false, and I have tried the simple route in FodyWeavers.xml:

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

and a more complex is:

<?xml version="1.0" encoding="utf-8" ?> <Weavers> <Costura> <Unmanaged64Assemblies> Costura64\LibGit2Sharp Costura64\git2-1196807 </Unmanaged64Assemblies> <Unmanaged32Assemblies> Costura32\LibGit2Sharp Costura32\git2-1196807 </Unmanaged32Assemblies> </Costura> </Weavers>

However, I always get an error, not when opening the exe, but when I click the button that first uses the git library:

...'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'git2-1196807': The specified module could not be found. (Exception from HRESULT: 0x8007007E)...

A few things I've done have given me an error that the LibGet2Sharp dll is inaccessible (and not the error about git2-1196807), but I think that's just when I've crippled Fody.

I would appreciate any advice you can give; this has me baffled. If I put the git2-1196807.dll file in the deployed location ".\lib\win32\x86" and the 64bit equivalent, then it runs fine, but that defeats the point in using costura.fody.



Figured this out with some help from this question and had to add some work of my own.

Essentially, you need to create a pair of folders in the project, called Costura32 and Costura64 and put the appropriate version of the dll in there, and set them to 'Embedded resource'. Then the weaver can include them in the exe when building the solution.

In my case, I was using the LibGit2Sharp dll, which relies on git2-15e1193.dll, so I have this as part of my solution:

<img src=https://www.e-learn.cn/content/wangluowenzhang/"https://i.stack.imgur.com/r7oWE.png" alt="enter image description here">

and for each of those dll's, I have the Build Action set to Embedded Resource:

<img src=https://www.e-learn.cn/content/wangluowenzhang/"https://i.stack.imgur.com/ZQE6v.png" alt="enter image description here">

Finally, the FodyWeavers.xml is:

<?xml version="1.0" encoding="utf-8" ?> <Weavers> <costura IncludeDebugSymbls='false'> <Unmanaged32Assemblies> git2-15e1193 </Unmanaged32Assemblies> <Unmanaged64Assemblies> git2-15e1193 </Unmanaged64Assemblies> </costura> </Weavers>

Make sure to leave the .dll off the dll names in the FodyWeavers.xml file.


If LibGit2Sharp is a normal AnyCPU .net reference, then simply having it as a reference in the project is enough, don't embed it in the Costura32/Costura64 directories. Those directories are for normal Win32 style dlls that are loaded thru LoadLibrary and such.


  • Scala using regex with or syntax in match case statement
  • Debugging Android native application using ndk-gdb
  • How do I capture a rsolr Sunspot exception raised on a different thread from a model callback?
  • Why are “sc.addFile” and “spark-submit --files” not distributing a local file to all workers?
  • Are there any side effects from calling SQLAlchemy flush() within code?
  • How to resolve this packager error on react native Android
  • pickle.PicklingError: args[0] from __newobj__ args has the wrong class with hadoop python
  • Installing Perl6 and Panda on Ubuntu 15.10. Problems with bootstrap.pl
  • How to skip require in ruby?
  • Splash Screen will not display
  • import scipy.sparse failed
  • Xamarin Android | Layout style
  • Sending cookie value via httpget but not getting the desired response
  • CXF JAXB JAXBEncoderDecoder unmarshalling error : unexpected element when having qualified elements
  • python script hangs on input method when running spark
  • How to get current document uri in XSLT?
  • JBoss External Properties Files in Classpath
  • How to use JavaScript to determine whether a file exists in a directory?
  • ADO and msqli connections very slow
  • Android - Material Design - NavigationView - How to put vertical scroll?
  • Why Encoding.ASCII != ASCIIEncoding.Default in C#?
  • PHP buffered output depending on server setting?
  • Bad request using file_get_contents for PUT request in PHP
  • Jquery UI tool tip close icon
  • When to use `image` and when to use `Matrix` in Emgu CV?
  • Encrypt data by using a public key in c# and decrypt data by using a private key in php
  • Uncaught Error: Could not find module `ember-load-initializers`
  • Is possible to count alias result on mysql
  • SSO with signing and signature validation doesn't work
  • Deserializing XML into class C#
  • Calling of Constructors in a Java
  • How to include full .NET prerequisite for Wix Burn installer
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • sending mail using smtp is too slow
  • Binding checkboxes to object values in AngularJs
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize