Description
Steps to reproduce:
- mono nuget.exe install GitVersion.CommandLine -Version 3.5.2
- mono ./GitVersion.CommandLine.3.5.2/tools/GitVersion.exe
Output:
System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: git2-381caf5
at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods:git_libgit2_init ()
at LibGit2Sharp.Core.NativeMethods+LibraryLifetimeObject..ctor () <0x1fa8ae0 + 0x0000b> in :0
at LibGit2Sharp.Core.NativeMethods..cctor () <0x1fa8908 + 0x00107> in :0
Comparing the GitVersion.CommandLine package to the GitVersionTask package (which does work on OS X), the difference is that GitVersionTask includes a GitVersionTask.dll.config file which uses the Mono dllmap capability to map libgit2 for each system; GitVersion.CommandLine does not contain a similar config file. Copying the config file from GitVersionTask to GitVersion.CommandLine (and renaming it to GitVersion.exe.config) causes GitVersion.exe to work correctly.
I will look into creating a PR with a fix to the GitVersion.CommandLine package in the next couple of days, unless someone beats me to it.
Also, since the docs say to open an issue about why I want to use the GitVersion.CommandLine package, let me add that note here:
- I cannot use the Chocolatey package for two reasons:
- Different projects on my (or any other) machine may be using different versions of GitVersion, making it dangerous to rely on a GitVersion that is installed machine-wide
- I am building on OS X
- I don't want to use the GitVersionTask package, because it only works in MSBuild. I do not want determining my version number to be tied to MSBuild, because MSBuild is not my primary build tool (although like most .NET projects I am dependent on it for compilation for the time being). For example, there is no easy way to pass the version from GitVersion to my "nuget pack" command.
- The typical solution of using the "$version$" replacement token in the nuspec to substitute the version from the assembly only works when packing based on a csproj, which doesn't work when running NuGet in mono. I am forced to pack based on the nuspec, and therefore must pass the version directly.
- I don't want to check in GitVersion.exe to my source repository for the same reasons I don't want to check in any external dependencies to my source repository: I lose the ability to easily track and update the versions of my dependencies that NuGet gives me.
For these reasons, the GitVersion.CommandLine package is the best solution for me. Hopefully it can be maintained as a first-class citizen in the future.