You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GitVersionTask on the dotnet SDK docker image (microsoft/dotnet:2.1-sdk; Debian 9) #1473
So, I'm using GitVersionTask in my Docker build (using the officical microsoft/dotnet:2.1-sdk image). The issue I was having is the following error:
Could not determine assembly version: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'git2-15e1193' or one of its dependencies.
How I fixed it, is by install the library system wide and symlinking the location it's searching (used the LD_DEBUG env var to check what it was doing). In my Dockerfile I now have:
FROM microsoft/dotnet:2.1-sdk as builder
# Fix GitVersionTask build issue
RUN apt-get update && \
apt-get install -y libgit2-dev && \
ln -s /usr/lib/x86_64-linux-gnu/libgit2.so /lib/x86_64-linux-gnu/libgit2-15e1193.so
.... other build steps
I created the issue just to let you know. The current version (15e1193) is hardcoded above, so it might change depending on the LibGit2Sharp.Core.NativeMethods library version is used.
Reacted by Alessio Parma, Asbjørn Ulsberg, Daniel Girodat, Augustin Šulc and Ilia Tsvetkov
How are you using GitVersionTask inside this docker image? Can u share pls ?
Just install the NuGet package GitVersionTask (I have version 4.0.0-beta0014 installed) and build your project. Check the output dll file and you'll see the assembly version has been updated.
@arturcic I've installed GitVersionTask 4.0.0 and tried the build the project inside the microsoft/dotnet:2.1-sdk docker image, but still same error. I also tried to install libgit2-dev without symlinking the libraries, but to no avail:
MSBUILD : warning : WARN [10/23/18 7:59:06:37] Could not determine assembly version: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'git2-15e1193' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgit2-15e1193: cannot open shared object file: No such file or directory
@dazinator Yeah, that's what I thought however Artur explicitly asked me to redo the test with the 2.1 version. Either way, let's wait until the PR is merged. ;-)
@arturcic my guess is that the docker images we have currently for 2.1.0 are just calling dotnet gitversion which is slightly different from calling dotnet build (or msbuild) within the image to build a csproj file under dotnet sdk 2.1.0 cli, which loads and executes GitVersionTask. As far as I know the PR in question enables GitVersionTask to run in that second scenario. If things already work fine on 2.1.0 (including gitversiontask) then it would make me question the purpose of that outstanding PR..
We should probably rename that PR to make it super clear that its a gitversiontask thing. GitVersion itself already runs on 2.1.0 as you have said! But i think there may have been some other changes in it like the global tool stuff so I guess its now more of a conglomorate of things :-)
@j2ghz I assume if you try that on a 2.0.0 sdk it works? It sounds like you are also waiting for this PR to allow GitVersionTask to execute on >= 2.1.0 (simultaneously deprecating support for sdk 1.1.0)
I guess so. I used the fix from the first post, which helped. In the end I turned gitversion off in docker builds, since I get Could not determine assembly version: System.InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely., even after unshallow. Since it works at Appveyor and Travis, just not at Docker Hub, I think I'll just move the build to one of them.
If it helps - it appears as if the current version of the GitVersion.Tool (5.0.0-beta2-91) ships a version of the libgit2 lib (libgit2-15e1193.so) that depends on OpenSSL 1.0.0, which is not present in microsoft/dotnet:sdk, which is based on Debian Stretch.
This (rather ugly) workaround seems to work, by installing OpenSSL 1.0.0 from Debian Jessie:
deb http://httpredir.debian.org/debian jessie main contrib non-free
deb-src http://httpredir.debian.org/debian jessie main contrib non-free
deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free
Activity
brunobertechini commentedon Sep 16, 2018
How are you using GitVersionTask inside this docker image? Can u share pls ?
gerwim commentedon Sep 19, 2018
Just install the NuGet package GitVersionTask (I have version 4.0.0-beta0014 installed) and build your project. Check the output dll file and you'll see the assembly version has been updated.
dazinator commentedon Oct 10, 2018
For running on net.core 2.1.0 perhaps it's because you need #1422 ?
arturcic commentedon Oct 19, 2018
@gerwim can you validate this agains the latest v.4.0.0 version and close the issue ? Thanks
gerwim commentedon Oct 23, 2018
@arturcic I've installed GitVersionTask 4.0.0 and tried the build the project inside the microsoft/dotnet:2.1-sdk docker image, but still same error. I also tried to install
libgit2-devwithout symlinking the libraries, but to no avail:dazinator commentedon Oct 23, 2018
As above, I think you need the .net core 2.1 support which is in #1422 and not yet merged..
Otherwise try with a net core sdk 2.0 docker image.
gerwim commentedon Oct 23, 2018
@dazinator Yeah, that's what I thought however Artur explicitly asked me to redo the test with the 2.1 version. Either way, let's wait until the PR is merged. ;-)
arturcic commentedon Oct 23, 2018
I did that because the docker images that we currently have for version 4.0.0 are using microsoft/dotnet:2.1-runtime and they do work.
dazinator commentedon Oct 23, 2018
@arturcic my guess is that the docker images we have currently for 2.1.0 are just calling
dotnet gitversionwhich is slightly different from callingdotnet build(or msbuild) within the image to build a csproj file under dotnet sdk 2.1.0 cli, which loads and executesGitVersionTask. As far as I know the PR in question enablesGitVersionTaskto run in that second scenario. If things already work fine on 2.1.0 (including gitversiontask) then it would make me question the purpose of that outstanding PR..arturcic commentedon Oct 23, 2018
you're absolutely right
dazinator commentedon Oct 23, 2018
We should probably rename that PR to make it super clear that its a gitversiontask thing. GitVersion itself already runs on 2.1.0 as you have said! But i think there may have been some other changes in it like the global tool stuff so I guess its now more of a conglomorate of things :-)
j2ghz commentedon Oct 24, 2018
I have the same problem, here is a sample Dockerfile:
At this time I tested it
sdkis equivalent to2.1.403-sdk-stretch2.1-sdk-stretch2.1.403-sdk2.1-sdksdklatestdazinator commentedon Oct 24, 2018
@j2ghz I assume if you try that on a
2.0.0sdk it works? It sounds like you are also waiting for this PR to allow GitVersionTask to execute on >= 2.1.0 (simultaneously deprecating support for sdk 1.1.0)j2ghz commentedon Oct 24, 2018
I guess so. I used the fix from the first post, which helped. In the end I turned gitversion off in docker builds, since I get
Could not determine assembly version: System.InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely., even after unshallow. Since it works at Appveyor and Travis, just not at Docker Hub, I think I'll just move the build to one of them.arturcic commentedon Apr 19, 2019
#1659
driseley commentedon May 14, 2019
If it helps - it appears as if the current version of the
GitVersion.Tool(5.0.0-beta2-91) ships a version of the libgit2 lib (libgit2-15e1193.so) that depends on OpenSSL 1.0.0, which is not present inmicrosoft/dotnet:sdk, which is based on Debian Stretch.This (rather ugly) workaround seems to work, by installing OpenSSL 1.0.0 from Debian Jessie:
Dockerfile:
jsessie.list:
arturcic commentedon Jun 27, 2019
With the latest version there is no need for the workaround.
You can have a look at the way we ship the docker image with gitversion included https://github.com/GitTools/GitVersion/blob/master/src/Docker/netcoreapp2.1/linux/debian-9/Dockerfile
There is no need to install
libgit2-devand add symlinkarturcic commentedon Jun 27, 2019
As LibGit2Sharp was upgraded to version 0.26 in #1713, I think this problem is fixed. Please reopen this issue if the problem persists.