Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception #79

Open
vpaulino opened this issue Sep 25, 2018 · 8 comments

Comments

@vpaulino
Copy link

vpaulino commented Sep 25, 2018

Hi there

Im using package=Cake.Git on my cake script.... and it works on my machine :) but when I execute my build in my Jenkins CI it happens an error during script execution reporting an error with this log: "The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception".
My Cake.Git package version is the lastest Cake.Git.0.19.0 and the agent OS is Microsoft Windows Server Version 1607 (OS Build 14393.2485).

Does anyone knows anything about this ?

@devlead
Copy link
Member

devlead commented Sep 25, 2018

Which version of .NET is installed?

Currently libgit2sharp requires .NET 4.7.2 / .NET Core 2, there's PR fir Libgit2Sharp to support 4.6.1 and once that's published I'll release a new version of Cake.Git.

@RickRen7575
Copy link

@vpaulino do you know what resolved this issue? I am seeing the same issue.

@GnktYnk
Copy link

GnktYnk commented May 21, 2020

@vpaulino @RickRen7575 Did you resolve the issue or if it is resolved, possible to explain how it solved?

Cake.Git Version: 0.21.0
.NET Framework Version: 4.8

@vpaulino
Copy link
Author

vpaulino commented Sep 1, 2020

sorry for my disapearing on this. From what I recall on this the problem was the framework dotnet installed on the machine.. it was installed .Net 4.6, after upgrade it works. Sorry for the late answer... 2 years after.

@CDTR-MattConroy
Copy link

I am having this issue on MacOS. I'm using Cake 3.0.0, Cake.Git 3.0.0, and dotnet 7.0.102
It works fine on my Windows machine, but gets the same error message as above on MacOS:
The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception

@ehuna
Copy link

ehuna commented May 4, 2023

Same here, on a Mac M1 now getting this error using Cake 2.0.0, Cake.Git 2.0.0, and tried with dotnet 7.0.203 and dotnet 6.0.408.

@CDTR-MattConroy
Copy link

@ehuna I managed to work around the issue by installing version 0.27.0-preview-0175. This is a preview version, but seems to not have the issue on Mac

@ehuna
Copy link

ehuna commented Aug 8, 2023

@CDTR-MattConroy thanks, we tried but that did not work for us. We ended up using git directly and no longer using Cake.Git.

For example instead of using GitLogTip(), we wrote our own like this -

private string GetGitHash()
{
    StartProcess(
        "git",
        new ProcessSettings()
            .WithArguments(x => x
                .Append("rev-parse")
                .Append("HEAD"))
            .SetRedirectStandardOutput(true),
            out var lines);

    var githash = string.Join(Environment.NewLine, lines);
    var result = githash.Trim();

    Information($"From GetGitHash(): {result}");

    return result;
}

wazzamatazz added a commit to wazzamatazz/cake-recipes that referenced this issue Nov 28, 2024
Cake.Git does not work on MacOS (cake-contrib/Cake_Git#79)

We only used it to get the current branch name so we can just call git directly to get it instead.
wazzamatazz added a commit to wazzamatazz/cake-recipes that referenced this issue Nov 28, 2024
* Remove use of Cake.Git

Cake.Git does not work on MacOS (cake-contrib/Cake_Git#79)

We only used it to get the current branch name so we can just call git directly to get it instead.

* Update version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants