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

4.0.1-beta1-53: Fails to find the LibGit2Sharp. #1550

Closed
LordMike opened this issue Dec 13, 2018 · 26 comments
Closed

4.0.1-beta1-53: Fails to find the LibGit2Sharp. #1550

LordMike opened this issue Dec 13, 2018 · 26 comments
Assignees
Labels
Milestone

Comments

@LordMike
Copy link

This compiled before lunch :P

> dotnet build
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 24,17 ms for C:\Src\Project.csproj.
[NuGet Minimal]: Restoring packages for C:\Users\MichaelBisbjerg\.nuget\packages\gitversiontask\4.0.1-beta1-53\build\functionality\GitVersionBuild.targets...
[NuGet Minimal]: Restoring packages for C:\Users\MichaelBisbjerg\.nuget\packages\gitversiontask\4.0.1-beta1-53\build\functionality\GitVersionBuild.targets...
MSBUILD : warning : WARN [12/13/18 13:00:50:51] Could not determine assembly version: System.IO.FileNotFoundException: Could not load file or assembly 'LibGit2Sharp, Version=0.26.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333'. The system cannot find the file specified. [C:\Src\Project.csproj]
MSBUILD : warning : File name: 'LibGit2Sharp, Version=0.26.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333' ---> System.IO.FileNotFoundException: Could not load the specified file. [C:\Src\Project.csproj]
MSBUILD : warning : File name: 'LibGit2Sharp' [C:\Src\Project.csproj]
MSBUILD : warning :    at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName) [C:\Src\Project.csproj]
MSBUILD : warning :    at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName) [C:\Src\Project.csproj]
MSBUILD : warning :    at GitVersion.GitPreparer.GetDotGitDirectory() [C:\Src\Project.csproj]
MSBUILD : warning :    at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache) in C:\projects\gitversion\src\GitVersionCore\ExecuteCore.cs:line 33 [C:\Src\Project.csproj]
MSBUILD : warning :    at GitVersion.ExecuteCore.TryGetVersion(String directory, VersionVariables& versionVariables, Boolean noFetch, Authentication authentication) in C:\projects\gitversion\src\GitVersionCore\ExecuteCore.cs:line 82 [C:\Src\Project.csproj]
MSBUILD : warning :  [C:\Src\Project.csproj]
MSBUILD : warning :  [C:\Src\Project.csproj]
MSBUILD : warning : WARN [12/13/18 13:00:50:54] Could not determine assembly version: System.IO.FileNotFoundException: Could not load file or assembly 'LibGit2Sharp, Version=0.26.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333'. The system cannot find the file specified. [C:\Src\Project.csproj]
MSBUILD : warning : File name: 'LibGit2Sharp, Version=0.26.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333' ---> System.IO.FileNotFoundException: Could not load the specified file. [C:\Src\Project.csproj]
MSBUILD : warning : File name: 'LibGit2Sharp' [C:\Src\Project.csproj]
MSBUILD : warning :    at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName) [C:\Src\Project.csproj]
MSBUILD : warning :    at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName) [C:\Src\Project.csproj]
MSBUILD : warning :    at GitVersion.GitPreparer.GetDotGitDirectory() [C:\Src\Project.csproj]
MSBUILD : warning :    at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache) in C:\projects\gitversion\src\GitVersionCore\ExecuteCore.cs:line 33 [C:\Src\Project.csproj]
MSBUILD : warning :    at GitVersion.ExecuteCore.TryGetVersion(String directory, VersionVariables& versionVariables, Boolean noFetch, Authentication authentication) in C:\projects\gitversion\src\GitVersionCore\ExecuteCore.cs:line 82 [C:\Src\Project.csproj]
MSBUILD : warning :  [C:\Src\Project.csproj]
MSBUILD : warning :  [C:\Src\Project.csproj]
MSBUILD : warning : WARN [12/13/18 13:00:50:57] Could not determine assembly version: System.IO.FileNotFoundException: Could not load file or assembly 'LibGit2Sharp, Version=0.26.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333'. The system cannot find the file specified. [C:\Src\Project.csproj]
MSBUILD : warning : File name: 'LibGit2Sharp, Version=0.26.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333' ---> System.IO.FileNotFoundException: Could not load the specified file. [C:\Src\Project.csproj]
MSBUILD : warning : File name: 'LibGit2Sharp' [C:\Src\Project.csproj]
MSBUILD : warning :    at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName) [C:\Src\Project.csproj]
MSBUILD : warning :    at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName) [C:\Src\Project.csproj]
MSBUILD : warning :    at GitVersion.GitPreparer.GetDotGitDirectory() [C:\Src\Project.csproj]
MSBUILD : warning :    at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache) in C:\projects\gitversion\src\GitVersionCore\ExecuteCore.cs:line 33 [C:\Src\Project.csproj]
MSBUILD : warning :    at GitVersion.ExecuteCore.TryGetVersion(String directory, VersionVariables& versionVariables, Boolean noFetch, Authentication authentication) in C:\projects\gitversion\src\GitVersionCore\ExecuteCore.cs:line 82 [C:\Src\Project.csproj]
MSBUILD : warning :  [C:\Src\Project.csproj]
MSBUILD : warning :  [C:\Src\Project.csproj]
C:\Program Files\dotnet\sdk\2.1.500\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.GenerateAssemblyInfo.targets(161,5): error MSB4044: The "GetAssemblyVersion" task was not given a value for the required parameter "NuGetVersion". [C:\Src\Project.csproj]

Build FAILED.
@adamshergold
Copy link

Same for me! I picked up beta-53 and get same issue. Have explicitly fixed dependency to be on beta-51 for the moment (which works).

@arturcic
Copy link
Member

@kll can you have a look?

@kll
Copy link
Contributor

kll commented Dec 14, 2018

Unfortunately I'm under a pretty big time crunch at work and don't have the time to look at other stuff. I also don't really use or understand how GitVersionTask works so I don't have much to go on. Just based on the error message though I followed a hunch and downloaded the gitversiontask-4.0.1-beta1-53.nupkg file and decompressed it to look at the files. The build/net461 directory contains LibGit2Sharp.dll and the lib folder with the native bits but the build/netstandard2.0 folder does not. So I assume it's just a packaging issue. I tried to glance through the project and build scripts and couldn't immediately understand how that package is produced to include the files directly rather than as nuget references like in the other projects that produce nuget packages.

That's all the time I can spend on it for now but hopefully it points someone more knowledgeable than I in the right direction.

@arturcic
Copy link
Member

Thanks, yes that's a good start, I'll try to find some time and check why it's not adding to the netstandard2.0

@arturcic arturcic self-assigned this Dec 21, 2018
@arturcic arturcic added the bug label Dec 21, 2018
arturcic pushed a commit that referenced this issue Dec 21, 2018
@arturcic arturcic added this to the 5.0.0 milestone Dec 21, 2018
@arturcic
Copy link
Member

@LordMike can you try the new build 4.0.1-beta1-55?

@LordMike
Copy link
Author

I now get this. While it's just a Warning, the build fails for completely different reasons - Jetbrains attributes are missing.. It still does build in 4.0.1-beta1-51, fails as before in -53 , and fails like below in -55.

MSBUILD : warning : WARN [12/22/18 4:11:12:00] Could not determine assembly version: System.Runtime.InteropServices.MarshalDirectiveException: StrictFilePathMarshaler must be used on a FilePath. [C:\Project\Project.csproj]
MSBUILD : warning :    at LibGit2Sharp.Core.StrictFilePathMarshaler.MarshalManagedToNative(Object managedObj) in C:\projects\libgit2sharp\LibGit2Sharp\Core\FilePathMarshaler.cs:line 71 [C:\Project\Project.csproj]
MSBUILD : warning :    at System.StubHelpers.MngdRefCustomMarshaler.ConvertContentsToNative(IntPtr pMarshalState, Object& pManagedHome, IntPtr pNativeHome) [C:\Project\Project.csproj]
MSBUILD : warning :    at LibGit2Sharp.Core.NativeMethods.git_repository_discover(GitBuf buf, FilePath start_path, Boolean across_fs, FilePath ceiling_dirs) [C:\Project\Project.csproj]
MSBUILD : warning :    at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever) in C:\projects\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 3553 [C:\Project\Project.csproj]
MSBUILD : warning :    at LibGit2Sharp.Repository.Discover(String startingPath) in C:\projects\libgit2sharp\LibGit2Sharp\Repository.cs:line 645 [C:\Project\Project.csproj]
MSBUILD : warning :    at GitVersion.GitPreparer.GetDotGitDirectory() in C:\projects\gitversion\src\GitVersionCore\GitPreparer.cs:line 163 [C:\Project\Project.csproj]
MSBUILD : warning :    at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache) in C:\projects\gitversion\src\GitVersionCore\ExecuteCore.cs:line 33 [C:\Project\Project.csproj]
MSBUILD : warning :    at GitVersion.ExecuteCore.TryGetVersion(String directory, VersionVariables& versionVariables, Boolean noFetch, Authentication authentication) in C:\projects\gitversion\src\GitVersionCore\ExecuteCore.cs:line 82 [C:\Project\Project.csproj]

@asbjornu
Copy link
Member

If 459bf46 managed to reduce the error to a warning, is this not a blocker anymore so we can continue as planned in #1422 (comment)?

@asbjornu
Copy link
Member

@LordMike, @arturcic: What say ye? ☝️

@arturcic
Copy link
Member

To be honest I would prefer to test it myself, just need a sample how to do that, so that next time I can confirm if it's working, @LordMike could you provide a sample of the project that has the GitVersion Task configured, as I prefer using the global tool instead of msbuild.

@LordMike
Copy link
Author

We no longer use the task. It had some other rather horrendous implications, such as being very slow for multiple projects and not supporting parallel operations. As of this comment we moved to an entirely build-script managed approach, where the scripe (Nuke) handles the Gitversion CLI and does magic.

So, right now, I won't be able to contribute a working (failing) example. Although, it shouldn't be hard to reproduce?

arturcic added a commit that referenced this issue Jan 23, 2019
using older GitTools.Core package instead of project
@arturcic
Copy link
Member

I was able to reproduce it locally, have create a sample console app with the GitVersionTask nuget package installed. I was able to fix it by partially reverting the commit related to .net standard 2.0 support. The 2.0 remains in place, the GitTools.Core is not included by source but using the nuget package, the old way. I'll try to fix GitTool.Core in it's repo, and then updated it in GitVersion. For now we'll use the older version of GitTools.Core

@arturcic
Copy link
Member

@adamshergold can you test the version 4.0.1-beta1-59? I guess @LordMike will not be able to test it.

@adamshergold
Copy link

Hi @arturcic ... i've tried with beta1-59 and it's okay IF I install libgit2-dev in the dotnet-sdk container before starting the build. I do this as part of my gitlab build steps:

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

If I don't do this then I get errors like this:

MSBUILD : warning : WARN [01/24/19 10:57:21:20] 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 [/builds/adamshergold/example.types/example.types.schema/example.types.schema.fsproj]
MSBUILD : warning : at LibGit2Sharp.Core.NativeMethods.git_libgit2_init() [/builds/adamshergold/example.types/example.types.schema/example.types.schema.fsproj]
MSBUILD : warning : at LibGit2Sharp.Core.NativeMethods.LoadNativeLibrary() [/builds/adamshergold/example.types/example.types.schema/example.types.schema.fsproj]
MSBUILD : warning : at LibGit2Sharp.Core.NativeMethods..cctor() [/builds/adamshergold/example.types/example.types.schema/example.types.schema.fsproj]

Happy to give you access to my gitlab build if you want to look further and/or am very happy to help out with further investigation.

thanks!

@arturcic
Copy link
Member

That is expected, as I had to revert to older version of GitTools.Core nuget package that was using the old LibGit2Sharp. So it should work exactly the same as beta1-51, the one before the merge of #1422. I will try to update the GitTools.Core nuget package with the latest and then use it in GitVersion, hope we will not need to do the workaround

@arturcic
Copy link
Member

So it is basically GitVersion on netstandard 2.0 using LibGit2Sharp version netstandard 1.3 I guess

@adamshergold
Copy link

adamshergold commented Jan 24, 2019

Sounds good. I'll stick with beta1-59 and the libgit2-dev install for the time-being.

feitzi added a commit to feitzi/AbstractEnum.Net that referenced this issue Jan 27, 2019
@twsl
Copy link

twsl commented Feb 5, 2019

suggested solution with manual install doesn't work on alpine images

@Svetomechc
Copy link

@twsI use builds with two stages. The first one would rely on microsoft/dotnet:dotnet:2.2-sdk, the second one would be microsoft/dotnet:2.2-aspnetcore-runtime-alpine. This is the most painless solution I've found so far, with resulting image size being okay-ish.

@arturcic arturcic added Bug bug and removed bug labels Mar 7, 2019
@bonesoul
Copy link

any updates on this?

@arturcic
Copy link
Member

#1659

@bonesoul
Copy link

bonesoul commented May 8, 2019

i'm using 5.0.0-beta2-75 on an ubuntu 14.04 build with libcurl3 installed but still getting

MSBUILD : warning : WARN [05/08/19 12:26:01:82] 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 [/temp/src/hypeengine.twitch/hypeengine.twitch.csproj]

@arturcic
Copy link
Member

@adamshergold , @bonesoul can you try the latest version?

@asbjornu
Copy link
Member

As LibGit2Sharp was upgraded to version 0.26 in #1713, I think this problem is fixed. Please reopen this issue if the problem persists.

@sandorfr
Copy link

@asbjornu looks like it's still happening with the vsts extension on Mac agents:


ERROR [07/25/19 10:47:38:08] An unexpected error occurred: |  
-- | --
  | System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: git2-15e1193 |  
  | at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods.git_libgit2_init() |  
  | at LibGit2Sharp.Core.NativeMethods.LoadNativeLibrary () [0x00000] in <824ee26b2afa49d5948582decd2171d3>:0 |  
  | at LibGit2Sharp.Core.NativeMethods..cctor () [0x00054] in <824ee26b2afa49d5948582decd2171d3>:0 |  
  | --- End of inner exception stack trace --- |  
  | at LibGit2Sharp.Core.Proxy.git_buf_free (LibGit2Sharp.Core.Handles.GitBuf buf) [0x00000] in <824ee26b2afa49d5948582decd2171d3>:0 |  
  | at LibGit2Sharp.Core.Handles.GitBuf.Dispose () [0x00000] in <824ee26b2afa49d5948582decd2171d3>:0 |  
  | at LibGit2Sharp.Core.Proxy.ConvertPath (System.Func`2[T,TResult] pathRetriever) [0x0002e] in <824ee26b2afa49d5948582decd2171d3>:0 |  
  | at LibGit2Sharp.Core.Proxy.git_repository_discover (LibGit2Sharp.Core.FilePath start_path) [0x00005] in <824ee26b2afa49d5948582decd2171d3>:0 |  
  | at LibGit2Sharp.Repository.Discover (System.String startingPath) [0x00006] in <824ee26b2afa49d5948582decd2171d3>:0 |  
  | at GitVersion.GitPreparer.GetDotGitDirectory () [0x0000f] in <824ee26b2afa49d5948582decd2171d3>:0 |  
  | at GitVersion.GitPreparer.GetProjectRootDirectory () [0x00048] in <824ee26b2afa49d5948582decd2171d3>:0 |  
  | at GitVersion.ConfigurationProvider.Verify (GitVersion.GitPreparer gitPreparer, GitVersion.Helpers.IFileSystem fileSystem) [0x00014] in <824ee26b2afa49d5948582decd2171d3>:0 |  
  | at GitVersion.Program.VerifyConfiguration (GitVersion.Arguments arguments, GitVersion.Helpers.IFileSystem fileSystem) [0x00023] in <824ee26b2afa49d5948582decd2171d3>:0 |  
  | at GitVersion.Program.VerifyArgumentsAndRun () [0x00118] in <824ee26b2afa49d5948582decd2171d3>:0

@arturcic
Copy link
Member

@sandorfr
Copy link

@arturcic it was the was I tried for I actually switch to the normal one with 5.0 and it works.

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

No branches or pull requests

9 participants