Problems merging OpenCV assemblies with Costura

483 Views Asked by At

Currently, I have a C++/CLI wrapper project which references some OpenCV dlls. The wrapper project is then referenced by a C# library project I created.

Using Costura, the wrapper gets correctly merged within my C# library but the OpenCV dlls are not getting merged (because they're not referenced directly by my C# proj with copy local set to true).

I put all of the OpenCV assemblies into a costura64 folder located in the root of my project and added the Unmanaged64Assemblies element with all the required OpenCV dlls listed into the weavers xml to no avail.

I also added the IncludeAssemblies element to the Weavers xml with all of the required OpenCV dlls which causes an error while building:

MSBUILD : error : Fody/Costura: Assembly 'Imaging' cannot be found (not even as CopyLocal='false'), please update the configuration

My Weavers XML looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
 <Costura>
  <IncludeAssemblies>
   Imaging
   msvcp100d
   msvcp110d
   msvcr100d
   opencv_core247
   opencv_core247d
   opencv_highgui247
   opencv_highgui247d
   opencv_imgproc247
   opencv_imgproc247d
   PvAPI
</IncludeAssemblies>
<Unmanaged64Assemblies>
  Imaging
  msvcp100d
  msvcp110d
  msvcr100d
  opencv_core247
  opencv_core247d
  opencv_highgui247
  opencv_highgui247d
  opencv_imgproc247
  opencv_imgproc247d
  PvAPI
</Unmanaged64Assemblies>
</Costura>
</Weavers>

All assemblies currently have a Build Action of Embedded Resource.

Any help with what I need to do to merge the OpenCV assemblies into my C# library project would be greatly appreciated.

1

There are 1 best solutions below

0
On

The Unmanaged64Assemblies block should contain the C++/CLI wrapper assembly.

The name is kind of misleading, it's actually a list of mixed mode assemblies. Even if they are correctly embedded when not listed here, they do need to be listed here for the dependency chain to work all the way to the native libs.

The native libraries don't need to be added to that list, they are not assemblies, just putting them in a costura64 folder and marking them as Embedded Resources is enough.