Gitversion: How to run GitVersion in Mono?

Created on 19 Jul 2017  路  2Comments  路  Source: GitTools/GitVersion

I tried to run GitVersion in Docker.

Debian Stretch:

FROM microsoft/aspnetcore-build:2.0.0-preview2

RUN apt-get update && apt-get install -y unzip mono-runtime libmono-system-core4.0-cil && \
    curl -L -o /tmp/GitVersion_3.6.5.zip https://github.com/GitTools/GitVersion/releases/download/v3.6.5/GitVersion_3.6.5.zip && \
    unzip -d /opt/GitVersion /tmp/GitVersion_3.6.5.zip && \
    rm /tmp/GitVersion_3.6.5.zip
root@39806c64d80e:/# mono /opt/GitVersion/GitVersion.exe
INFO [07/19/17 6:55:26:73] Working directory: /
INFO [07/19/17 6:55:26:74] IsDynamicGitRepository: False
ERROR [07/19/17 6:55:26:75] An unexpected error occurred:
System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: lib/linux/x86_64/libgit2-baa87df.so
  at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_libgit2_init ()
  at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00006] in <1a5aafd5a5444cd6a1420741ccbb6f8a>:0
  at LibGit2Sharp.Core.NativeMethods..cctor () [0x00058] in <1a5aafd5a5444cd6a1420741ccbb6f8a>:0
   --- End of inner exception stack trace ---
  at LibGit2Sharp.Core.Proxy.git_buf_free (LibGit2Sharp.Core.Handles.GitBuf buf) [0x00000] in <1a5aafd5a5444cd6a1420741ccbb6f8a>:0
  at LibGit2Sharp.Core.Handles.GitBuf.Dispose () [0x00000] in <1a5aafd5a5444cd6a1420741ccbb6f8a>:0
  at LibGit2Sharp.Core.Proxy.ConvertPath (System.Func`2[T,TResult] pathRetriever) [0x0002e] in <1a5aafd5a5444cd6a1420741ccbb6f8a>:0
  at LibGit2Sharp.Core.Proxy.git_repository_discover (LibGit2Sharp.Core.FilePath start_path) [0x0000d] in <1a5aafd5a5444cd6a1420741ccbb6f8a>:0
  at LibGit2Sharp.Repository.Discover (System.String startingPath) [0x00006] in <1a5aafd5a5444cd6a1420741ccbb6f8a>:0
  at GitVersion.GitPreparer.GetDotGitDirectory () [0x0000f] in <57cedcc684654481ace045b6d7bcc156>:0
  at GitVersion.GitPreparer.GetProjectRootDirectory () [0x00048] in <57cedcc684654481ace045b6d7bcc156>:0
  at GitVersion.ConfigurationProvider.Verify (GitVersion.GitPreparer gitPreparer, GitVersion.Helpers.IFileSystem fileSystem) [0x00006] in <57cedcc684654481ace045b6d7bcc156>:0
  at GitVersion.Program.VerifyConfiguration (GitVersion.Arguments arguments, GitVersion.Helpers.IFileSystem fileSystem) [0x00023] in <57cedcc684654481ace045b6d7bcc156>:0
  at GitVersion.Program.VerifyArgumentsAndRun () [0x000ba] in <57cedcc684654481ace045b6d7bcc156>:0
INFO [07/19/17 6:55:26:75]
INFO [07/19/17 6:55:26:75] Attempting to show the current git graph (please include in issue):
INFO [07/19/17 6:55:26:75] Showing max of 100 commits
ERROR [07/19/17 6:55:26:76] Couldn't dump the git graph due to the following error: System.TypeInitializationException: The type initializer for 'GitTools.LibGitExtensions' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly or one of its dependencies.
  at GitTools.Logging.LogProvider.GetLogger (System.String name) [0x00000] in <57cedcc684654481ace045b6d7bcc156>:0
  at GitTools.Logging.LogProvider.GetLogger (System.Type type) [0x00006] in <57cedcc684654481ace045b6d7bcc156>:0
  at GitTools.Logging.LogProvider.GetCurrentClassLogger () [0x00011] in <57cedcc684654481ace045b6d7bcc156>:0
  at GitTools.LibGitExtensions..cctor () [0x00000] in <57cedcc684654481ace045b6d7bcc156>:0
   --- End of inner exception stack trace ---
  at GitVersion.Program.VerifyArgumentsAndRun () [0x001b7] in <57cedcc684654481ace045b6d7bcc156>:0

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: lib/linux/x86_64/libgit2-baa87df.so
  at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_libgit2_init ()
  at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () [0x00006] in <1a5aafd5a5444cd6a1420741ccbb6f8a>:0
  at LibGit2Sharp.Core.NativeMethods..cctor () [0x00058] in <1a5aafd5a5444cd6a1420741ccbb6f8a>:0
   --- End of inner exception stack trace ---
  at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject.Finalize () [0x00000] in <1a5aafd5a5444cd6a1420741ccbb6f8a>:0

root@5f2b3625a654:/# mono --version
Mono JIT compiler version 4.6.2 (Debian 4.6.2.7+dfsg-1)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen

root@5f2b3625a654:/# cat /etc/debian_version
9.0

Most helpful comment

FROM microsoft/aspnetcore-build:2.0.0-preview2

RUN apt-get update && apt-get install -y unzip mono-runtime libmono-system-core4.0-cil libgit2-24 && \
    curl -L -o /tmp/GitVersion_3.6.5.zip https://github.com/GitTools/GitVersion/releases/download/v3.6.5/GitVersion_3.6.5.zip && \
    unzip -d /opt/GitVersion /tmp/GitVersion_3.6.5.zip && \
    rm /tmp/GitVersion_3.6.5.zip && \
    echo '<configuration><dllmap os="linux" cpu="x86-64" wordsize="64" dll="git2-baa87df" target="/usr/lib/x86_64-linux-gnu/libgit2.so.24" /></configuration>' > \
    /opt/GitVersion/LibGit2Sharp.dll.config

All 2 comments

It worked when I installed libgit2 library from repository and manually edited LibGit2Sharp.dll.config file.

apt-get install libgit2-24
<configuration>
    <dllmap os="linux" cpu="x86-64" wordsize="64" dll="git2-baa87df" target="/usr/lib/x86_64-linux-gnu/libgit2.so.24" />
    <dllmap os="osx" cpu="x86,x86-64" dll="git2-baa87df" target="lib/osx/libgit2-baa87df.dylib" />
</configuration>

https://github.com/GitTools/GitVersion/issues/1097#issuecomment-297019472

FROM microsoft/aspnetcore-build:2.0.0-preview2

RUN apt-get update && apt-get install -y unzip mono-runtime libmono-system-core4.0-cil libgit2-24 && \
    curl -L -o /tmp/GitVersion_3.6.5.zip https://github.com/GitTools/GitVersion/releases/download/v3.6.5/GitVersion_3.6.5.zip && \
    unzip -d /opt/GitVersion /tmp/GitVersion_3.6.5.zip && \
    rm /tmp/GitVersion_3.6.5.zip && \
    echo '<configuration><dllmap os="linux" cpu="x86-64" wordsize="64" dll="git2-baa87df" target="/usr/lib/x86_64-linux-gnu/libgit2.so.24" /></configuration>' > \
    /opt/GitVersion/LibGit2Sharp.dll.config
Was this page helpful?
0 / 5 - 0 ratings