Nerdbank.GitVersioning: GetBuildVersion task fails for full Framework builds

Repro steps

  • Create a new Console Application (.NET Framework)
  • Install package Nerdbank.GitVersionong (either using packages.config or <PackageReference/>)
  • Build the project

Error:

System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
File name: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at Nerdbank.GitVersioning.VersionOracle.Create(String projectDirectory, String gitRepoDirectory, ICloudBuild cloudBuild, Nullable`1 overrideBuildNumberOffset, String projectPathRelativeToGitRepoRoot)
   at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner()
   at MSBuildExtensionTask.ContextAwareTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

I tested this using both Visual Studio 2015 and 2017 (15.8.1) on both Windows 7 and Windows 10 machines.

I do not know if it is relevant, but the Console Application is targeting .NET 4.6.1

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 44 (1 by maintainers)

Commits related to this issue

Most upvoted comments

@AArnott I’ve been out of town, so I haven’t had a chance to take a look at it this yet. At this point it might be Tuesday before I’ll be able to. Wanted to let you know that it’s on my radar.

I’ll be so happy once we get rid of all the problematic native dependencies and fix this once and for all!

FYI LibGit2Sharp 0.26.0-preview-0062 is up on nuget.org and it includes a separate ubuntu.18.04-x64 binary.

I played around a little more and installing the .NET 4.7.1 Targeting pack solves the issue as this seems to put netstandard.dll into the GAC

Also there is a open PR for LibGit2Sharp that adds a net461 target (https://github.com/libgit2/libgit2sharp/pull/1606), I guess updating the referenced version of LibGit2Sharp once this lands on NuGet might solve the issue too.

@bording I’m adopting 0.26.0-preview-0070 but notice that as for supported RIDs, you have ubuntu.18.04-x64 but nothing for ubuntu 16. Which RID works on that one? Or I suppose since you now target .NET Core 2.0 you had to drop support for Ubuntu 16?

Based on the RID graph, Ubuntu 16 would end up using the linux-x64 RID, as it was previously doing.

Take a look at https://github.com/dotnet/corefx/blob/master/pkg/Microsoft.NETCore.Platforms/runtime.compatibility.json

For a given RID, that will show you the fallback options if the exact RID doesn’t exist in the package.

For example, here is ubuntu.16.04-x64:

 "ubuntu.16.04-x64": [
    "ubuntu.16.04-x64",
    "ubuntu.16.04",
    "ubuntu-x64",
    "ubuntu",
    "debian-x64",
    "debian",
    "linux-x64",
    "linux",
    "unix-x64",
    "unix",
    "any",
    "base"
  ],

@AArnott You can try installing both libcurl3 and libssl1.0.0 and see if that works. I think having those installed would get the existing linux-x64 binary working, until there’s a specific 18.04 lib that is built against libcurl4 and libssl1.1.

@bording: can you help decipher this log, which we got when updating to the latest libgit2sharp 0.26.0-preview-0054 release? ld_debug.zip

Unhandled Exception: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'git2-8e0b172' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgit2-8e0b172: cannot open shared object file: No such file or directory
   at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
   at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()
   at LibGit2Sharp.Core.NativeMethods..cctor()
   --- End of inner exception stack trace ---
   at LibGit2Sharp.Core.NativeMethods.git_libgit2_opts(Int32 option, UInt32 level, String path)
   at LibGit2Sharp.GlobalSettings.SetConfigSearchPaths(ConfigurationLevel level, String[] paths)
   at Nerdbank.GitVersioning.GitExtensions.OpenGitRepo(String pathUnderGitRepo)
   at Nerdbank.GitVersioning.Tool.Program.OnGetVersionCommand(String projectPath, String format, String versionOrRef) in D:\git\Nerdbank.GitVersioning\src\nbgv\Program.cs:line 235
   at Nerdbank.GitVersioning.Tool.Program.Main(String[] args) in D:\git\Nerdbank.GitVersioning\src\nbgv\Program.cs:line 104

❗️ Workaround: Use version 2.1.84 (which uses an older libgit2sharp dependency that didn’t have the bug).

libgit2/libgit2sharp#1606 is now merged, so framework moniker should be in next release.