Hello,
We recently updated to 2.2.13 (from 2.1.23) and are encountering an issue on OSX.
Tools:
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.
Thanks for your report. What version of OSX are you testing on?
Hi @AArnott , we're using High Sierra 10.13.2
Also on OSX 10.13.6.
Nerdbank.GitVersioning 2.1.84 does not exhibit the problem.
Oddly, dotnet build ... works (with 2.2.13) but msbuild … does not.
@rgmills What about you? Are you using dotnet build or msbuild?
Isn't msbuild only present when mono is installed? I haven't actively tested NB.GV with mono. It's quite the task just to make sure NB.GV works on .NET Framework, and all three OS's with .NET Core. Adding mono to the mix... that's a lot of work.
If dotnet build works, can you switch to using that?
Yes - that's msbuild on Mono. Can't switch for Xamarin iOS projects because the SDK is not available to dotnet build. I guess the same applies to Xamarin Android projects on Mac OS, but not sure since we build our Android projects on Windows.
If you have any pointers to where I might look, I would be happy to try to figure out what has changed between 2.1.84 and 2.2.13 to break Mono msbuild. Is there a way I can debug the msbuild task on a Mac? Also, how/where does TargetsPath get set?
Thanks, @frankbuckley. TargetsPath gets set here:
I have no idea how to debug mono msbuild on Mac. On Windows I'll sometimes add a Debugger.Launch() call to my msbuild task which pops up a JIT debugger dialog that I can use. I don't know if something similar is available on Mac.
Between 2.1.84 and 2.2.13 the primary change was adding support for Ubuntu 18 and other more recent linux distros. It was a _lot_ of trial-and-error changes to try to get everything working at once. It was a delicate balancing act. So if we can get this to work for mono, we'll need to revalidate on all the other platforms we support. I'm building up my prowess at Azure Pipelines build validations that include many different target OSs and versions that should help with that.
Yes, whatever you can do to help investigate would be much appreciated.
@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-L364
However, 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 the DllNotFoundException on Mono msbuild 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. Both dotnet build and .NET Framework msbuild on Windows work OK with this change.
I have been playing around with a test project that can be used to test with dotnet and msbuild 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?
Ah, yes that's great that putting those DLLs back solve the problem. I remember I removed them because they didn't appear to be needed any more -- not because they were causing any problem other than making the package bigger. I wonder if we can avoid the extra copy of DLLs by just adjusting the .targets files somehow... but I'm OK to bring them back if that's the only way we know how to go.
I appreciate all the validation you've done as well.
Regarding the LKG, that was a one-off change of source code where I added a PackageId property to the project and packed it, then pushed that package. I _think_ it was that simple, but as you can tell, it was a while back that I did it. It certainly warrants a refresher now, particular for the sake of the regression testing you mentioned. Let's get your existing fix in first (can you send a PR?) and then I can spin another LKG and then if you can prepare the change to get the tests running on multiple OSs smoke test it on each build system, that would be awesome.
👏 @frankbuckley highly appreciate you working on this since I just started running into this myself - unable to use vscode on Mac to work on projects at the moment.
Thanks @frankbuckley and @AArnott . Great surprise to see coming back from vacation!
Most helpful comment
@AArnott - I have made a start at figuring it out.
My first thought was this was the problem - in that it will return
lib/win32on 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 buildand fixes theDllNotFoundExceptionon Monomsbuildon 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 buildand .NET Frameworkmsbuildon Windows work OK with this change.I have been playing around with a test project that can be used to test with
dotnetandmsbuildwith 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?