TypeInitializationException on OSX
See original GitHub issueHello,
We recently updated to 2.2.13 (from 2.1.23) and are encountering an issue on OSX.
Tools:
- Visual Studio for Mac
- dotnet sdk v2.1.401
Below is the error output:
Target GetBuildVersion:
/Users/username/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly.
/Users/username/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: lib/osx/libgit2-6311e88.dylib
/Users/username/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: at (wrapper managed-to-native) LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
/Users/username/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: at LibGit2Sharp.Core.NativeMethods.LoadNativeLibrary () [0x00000] in <b59d5da32f8541b2a767004d8bddc22b>:0
/Users/username/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: at LibGit2Sharp.Core.NativeMethods..cctor () [0x00045] in <b59d5da32f8541b2a767004d8bddc22b>:0
/Users/username/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: --- End of inner exception stack trace ---
/Users/username/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: at LibGit2Sharp.Core.Proxy.git_libgit2_opts_set_search_path (LibGit2Sharp.ConfigurationLevel level, System.String path) [0x00000] in <b59d5da32f8541b2a767004d8bddc22b>:0
/Users/username/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: at LibGit2Sharp.GlobalSettings.SetConfigSearchPaths (LibGit2Sharp.ConfigurationLevel level, System.String[] paths) [0x0001a] in <b59d5da32f8541b2a767004d8bddc22b>:0
/Users/username/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: at Nerdbank.GitVersioning.GitExtensions.OpenGitRepo (System.String pathUnderGitRepo) [0x00012] in <150882c73d494e8384ad79d7674b0ae0>:0
/Users/username/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: at Nerdbank.GitVersioning.VersionOracle.Create (System.String projectDirectory, System.String gitRepoDirectory, Nerdbank.GitVersioning.ICloudBuild cloudBuild, System.Nullable`1[T] overrideBuildNumberOffset, System.String projectPathRelativeToGitRepoRoot) [0x00017] in <150882c73d494e8384ad79d7674b0ae0>:0
/Users/username/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner () [0x000c5] in <a9ad9b18f9d14576b838941f05d31209>:0
/Users/username/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: at MSBuildExtensionTask.ContextAwareTask.Execute () [0x0005e] in <a039684190264706bf075ac0ee99291f>:0
/Users/username/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in /_/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:631
/Users/username/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder+<ExecuteInstantiatedTask>d__26.MoveNext () [0x00212] in /_/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:787
Done building target "GetBuildVersion" in project "MyProject.csproj" -- FAILED.
Let me know if there is any additional information I can provide.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11
Top Results From Across the Web
TypeInitializationException:The type initializer for 'Gdip ...
I'm building an application that runs on both windows and macos. This application converts dng to bmp. On Windows (10) it works but...
Read more >dotnet core in macOS: "The type initializer for 'Crypto' threw ...
I followed the instructions on the .NET Core website, but got this error. Apparently there are some pre-reqs which are missing. Any idea...
Read more >Type initializer for 'Sdl' threw an exception (macOS)
TypeInitializationException : The type initializer for 'Sdl' threw an exception. ---> System.Exception: Failed to load SDL library. at Sdl.GetNativeLibrary ...
Read more >TypeInitializationException.TypeName Property (System)
Gets the fully qualified name of the type that fails to initialize.
Read more >Why i am getting TypeInitializationException - Microsoft Q&A
TypeInitializationException : The type initializer for 'Microsoft.Maui.Controls.Shapes.Shape' threw an exception. ---> System.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@AArnott - I have made a start at figuring it out.
My first thought was this was the problem - in that it will return
lib/win32
on Mono OSX: https://github.com/AArnott/Nerdbank.GitVersioning/blob/d0bbbacfe34e9540572e5747893f2897c892d64a/src/NerdBank.GitVersioning/GitExtensions.cs#L357-L364However, changing that did not fix the
DllNotFoundException
.The only thing I have found so far that ‘fixes’ (works around) the problem it is to put copies of the libraries back under MSBuildFull.
I have confirmed this does not break
dotnet build
and fixes theDllNotFoundException
on Monomsbuild
on Mac OS X 10.13.6 (MS Build 15.7.224 on Mono 5.12.0) and Ubuntu 18.04.1 (MS Build 15.6.0.0 on Mono 5.14.0. I have not tested Mono on Windows. Bothdotnet build
and .NET Frameworkmsbuild
on Windows work OK with this change.I have been playing around with a test project that can be used to test with
dotnet
andmsbuild
with local build artifacts. This could be used in CI builds to validate on multiple platforms. However, to build on OSX and Linux, Nerdbank.GitVersioning.LKG needs to be a version that works on those platforms. How do I make one?Thanks @frankbuckley and @AArnott . Great surprise to see coming back from vacation!