LibGit2Sharp在 Asp.Net Core 3.1 docker 镜像中中无法使用的问题

The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. Unable to load shared library 'git2-106a5f2' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgit2-106a5f2: cannot open shared object file: No such file or directory

搜索了很多, 看起来全地球大家都遇到了, 然后大家都解决了, 然后就我没解决, 

比如:加入   <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

或者加入

<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; </IncludeAssets>

把 linux-x64 下的  libgit2-106a5f2.so 拷贝到 程序目录  lib目录等, 都没有用。  

常识了各种方法, 问题依旧, 

折磨了一个小时后, 突然想到一个命令, ldd  , 于是在容器中执行了一下 ldd  libgit2-106a5f2.so 

 发现俩not  found , 看起来库不对劲。,最后查看容器的对应库版本是 1.1.0 ,查看了 libgit2sharp.nativebinaries\2.0.306\runtimes\ 下面  所有libgit2 的库 ldd 信息, 发现debian 9 是正确符合这个版本,

最后发现是由于项目的  RuntimeIdentifier 不设置默认是linux-64 ,然后项目加入  <RuntimeIdentifier>debian.9-x64</RuntimeIdentifier> 后, "libgit2sharp.nativebinaries\2.0.306\runtimes\debian.9-x64\native\libgit2-106a5f2.so" 文件使用的是 libssl.so.1.1.1 的版本   然后程序镜像重新打包重新运行, 一切OK . 

猜你喜欢

转载自www.cnblogs.com/MysticBoy/p/12302094.html