8000 scriptcs + libgit2sharp -> Unable to load DLL 'git2' · Issue #431 · libgit2/libgit2sharp · GitHub
[go: up one dir, main page]

Skip to content
scriptcs + libgit2sharp -> Unable to load DLL 'git2'  #431
Closed
@shiftkey

Description

@shiftkey

If someone wants to jump on this, the current way of "including" git2.dll doesn't work when you try and reference it inside a scriptcs script.

Repro: https://github.com/aaronpowell/scriptcs-git

Script:

using System;
using LibGit2Sharp;

static Repository InitOrOpen(string path)
{
    var gitBasePath = Repository.Discover(path);
    if (gitBasePath == null)
    {
        Console.WriteLine("And we're creating a new git repo people!");
        return Repository.Init(path);
    }
    Console.WriteLine("Found existing repo, keep on trucking");
    return new Repository(gitBasePath);
}

using (var repo = InitOrOpen(@"C:\temp\git-fun\out"))
{
    Console.WriteLine("It's time to rock and rooooooooll");
}

Console.ReadLine();

Then, in the directory containing this script:

scriptcs -install
scriptcs .\app.csx -debug

Which gives this output:

INFO : Starting to create execution components
INFO : Starting execution
ERROR: An error occurred when executing the scripts.
ERROR: Exception Message: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
Stack Trace:   at LibGit2Sharp.Core.NativeMethods.git_repository_discover(Byte[] repository_path, UIntPtr size, FilePath start_path, Boolean across_fs, FilePath ceiling_dirs)
   at LibGit2Sharp.Core.Proxy.<>c__DisplayClass1f.<git_repository_discover>b__1e(Byte[] buffer, UIntPtr bufSize)
   at LibGit2Sharp.Core.Proxy.ConvertPath(Func`3 pathRetriever)
   at LibGit2Sharp.Repository.Discover(String startingPath)
   at Submission#0..ctor(Session session, Object& submissionResult) in D:\Code\github\aaronpowell\scriptcs-git\.\app.csx:line 16
   at Submission#0.<Factory>(Session session)

Unhandled Exception: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'git2': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at LibGit2Sharp.Core.NativeMethods.git_threads_init()
   at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject..ctor()
   at LibGit2Sharp.Core.NativeMethods..cctor()
   --- End of inner exception stack trace ---
   at LibGit2Sharp.Core.NativeMethods.RemoveHandle()
   at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject.Finalize()

I don't expect the scriptcs guys to support PostBuildEvent like Visual Studio does, so I'm curious what our options might be for "really important stuff you need to do after installing a package" which seems to be the last opportunity to do that before scriptcs starts loading in assemblies.

cc @glennblock @aaronpowell

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0