Not able to get Costura.Fody to work, keeps asking for the DLL

蹲街弑〆低调 提交于 2019-12-10 10:16:41

问题


I have installed costura.fody into my project using nuget package. I have updated the FodyWeavers.xml file with:

<Costura 
Unmanaged32Assemblies='dllname'
Unmanaged64Assemblies='dllname' />

when I rebuild it and try to run the exe on seperate PC without the dll it doesnt work. Am I missing something ? Do I need to add anything else. I have also tried the following :

<IncludeAssemblies>
    dllname
</IncludeAssemblies>

Thank you for the help in advance.


回答1:


Make sure "Copy Local" is set to "True" within the reference properties tab on your desired libraries. Costura will not embed anything that does not have this setting enabled.




回答2:


I wanted to add an element to this that is important for unmanaged dll's when they aren't formally part of the solution/project.

@Adds is right to use:

<Costura 
Unmanaged32Assemblies='dllname'
Unmanaged64Assemblies='dllname' />

and @kdiddymcnasty is right to be careful about double-inclusion (but note that the IncludeAssemblies attribute is different from the Unmanaged##Assemblies attribute).

However, there's an additional piece to this, which is shown at this page. 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:

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

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.




回答3:


I was pulling my hair out with this issue and I couldn't find a solid answer. Eventually, I thought to look at the build output and noticed that it was embedding one of my dlls twice.

I had "Copy Local" set to "True" on that dll, and also included it in the FodyWeavers.xml, as @Adds did with "IncludeAssemblies" and "Unmanaged64Assemblies". When I set "Copy Local" to "False", the build output showed that it only embedded the dll once. When I ran the exe on a different PC, it worked fine.



来源:https://stackoverflow.com/questions/33695753/not-able-to-get-costura-fody-to-work-keeps-asking-for-the-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!