1
votes

I installed LibGit2Sharp and LibGit2Sharp.NativeBinaries with paket (first last stable version, then prerelease) and I am trying to use it in an F# script, but I keep getting this error:

Script1.fsx(3,1): error FS0229: Error opening binary file '../packages\LibGit2Sharp.NativeBinaries\runtimes\win7-x64\native\git2-381caf5.dll': ../packages\LibGit2Sharp.NativeBinaries\runtimes\win7-x64\native\git2-381caf5.dll: bad cli header, rva 0

Script1.fsx(3,1): error FS3160: Problem reading assembly '': Exception of type 'Microsoft.FSharp.Compiler.ErrorLogger+StopProcessing' was thrown.

I also tried referencing it in a C# project (VS2015 -> tried diff target frameworks: 4, 4.5.2 and 4.6.1), but I'm getting this error:

error adding reference

Same errors with the last stable version. Any idea what I'm doing incorrect?

1
My guess is that you are trying to reference C or C++ dlls in .NET. Can you show how you are referencing libgit2 in you code. Why do you need libgit btw? There are windows git clients. - s952163
I added the folder where the native libraries should reside. You don't need to reference it directly, but you do need to reference LibGit2Sharp. - s952163

1 Answers

2
votes

You should probably reference (in VS or via #r in FSI):

#r @"..\packages\LibGit2Sharp.0.23.0-pre20160803182831\lib\net40\LibGit2Sharp.dll"

I could do

open LibGit2Sharp
let myrepo = new Repository(@"..\Projects\StackOverflow5")

The error you got is really referring to the native libgit2 libraries and you don't need to reference them directly. However it's possible the LibGit2Sharp cannot find them. In that case place the x64 (or x86 if you're still stuck in 32-bit) git2-381-caf5.dll into the same folder where LibGit2Sharp.dll lives. In this case that's the same folder I'm referencing above:

\packages\LibGit2Sharp.0.23.0-pre20160803182831\lib\net40\