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

GetBuildVersion task fails on Ubuntu+Mono with error "MSB4018: System.BadImageFormatException: Method has no body" #224

Closed
AndrewKostousov opened this issue Sep 13, 2018 · 3 comments

Comments

@AndrewKostousov
Copy link

When building this project on Travis CI with Mono I get the following error:

/home/travis/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly. [/home/travis/build/skbkontur/gremit/AsmToBytes/AsmToBytes.csproj]
/home/travis/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: System.BadImageFormatException: Method has no body [/home/travis/build/skbkontur/gremit/AsmToBytes/AsmToBytes.csproj]
/home/travis/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: File name: 'LibGit2Sharp' [/home/travis/build/skbkontur/gremit/AsmToBytes/AsmToBytes.csproj]
/home/travis/.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  [/home/travis/build/skbkontur/gremit/AsmToBytes/AsmToBytes.csproj]
/home/travis/.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  [/home/travis/build/skbkontur/gremit/AsmToBytes/AsmToBytes.csproj]
/home/travis/.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  [/home/travis/build/skbkontur/gremit/AsmToBytes/AsmToBytes.csproj]
/home/travis/.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  [/home/travis/build/skbkontur/gremit/AsmToBytes/AsmToBytes.csproj]
/home/travis/.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  [/home/travis/build/skbkontur/gremit/AsmToBytes/AsmToBytes.csproj]
/home/travis/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:   at MSBuildExtensionTask.ContextAwareTask.Execute () [0x0005e] in <a039684190264706bf075ac0ee99291f>:0  [/home/travis/build/skbkontur/gremit/AsmToBytes/AsmToBytes.csproj]
/home/travis/.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 <bdc5207a22bb42ae9fe3f3d07e82871e>:0  [/home/travis/build/skbkontur/gremit/AsmToBytes/AsmToBytes.csproj]
/home/travis/.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 <bdc5207a22bb42ae9fe3f3d07e82871e>:0  [/home/travis/build/skbkontur/gremit/AsmToBytes/AsmToBytes.csproj]
Done Building Project "/home/travis/build/skbkontur/gremit/AsmToBytes/AsmToBytes.csproj" (default targets) -- FAILED.

Here are environment details:

Build system information:
Build language: csharp
Build group: stable
Build dist: trusty
Build id: 428225005
Job id: 428225007
Runtime kernel version: 4.14.12-041412-generic
travis-build version: cac5d41a1
Build image provisioning date and time
Tue Dec  5 20:11:19 UTC 2017
Operating System Details
Distributor ID:	Ubuntu
Description:	Ubuntu 14.04.5 LTS
Release:	14.04
Codename:	trusty

$ mono --version
Mono JIT compiler version 5.14.0.177 (tarball Mon Aug  6 09:14:27 UTC 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug
	Interpreter:   yes
	LLVM:          yes(3.6.0svn-mono-/)
	GC:            sgen (concurrent by default)

$ msbuild /version
Copyright (C) Microsoft Corporation. All rights reserved.
15.6.0.0

Actually, I do not need GNerdbank.GitVersioning machinery when running builds on Travis CI since I'm building and publishing NuGet packages from Appveyor, so for now I will use a workaround described here.

@AArnott
Copy link
Collaborator

AArnott commented Sep 13, 2018

@bording Do you recognize this failure? It's ubuntu 14 which I don't know if the version of libgit2sharp that I'm using supports any more. But even so, an empty method error that only shows up on mono but not dotnet core may be a sign of a mono bug.

@bording
Copy link

bording commented Sep 13, 2018

@AArnott No, that's a new one to me! I would expect Ubuntu 14 to still work, but we haven't been actively testing against mono for a while for due to some technical difficulties. We probably should revisit that and see if can get mono testing up and working again.

It sure would be nice if BadImageFormatException told you the name of the method that had no body!

@jarrodldavis
Copy link

jarrodldavis commented Oct 23, 2018

It appears the issue is with how the NuGet package is structured. In the build directory, the LibGit2Sharp.dll file and its accompanying DLL mapping configuration (LibGit2Sharp.dll.config) are in MSBuildCore and MSBuildFull folders; the native library files used by libgit2sharp are in a lib folder as a sibling to those MSBuild folders, but the DLL mapping configuration expects the native libraries to be in a lib folder as a sibling to LibGit2Sharp.dll.

TL;DR: copying the lib folder into the MSBuildFull folder fixes the issue for me.

Edit: I see you seem to have already fixed this in #222 and #227

I was facing this issue when trying to build https://github.com/AArnott/CodeGeneration.Roslyn on macOS and found this issue first, sorry.

@AArnott AArnott closed this as completed Oct 23, 2018
AArnott pushed a commit that referenced this issue Nov 15, 2023
Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 2.5.1 to 2.5.3.
- [Release notes](https://github.com/xunit/visualstudio.xunit/releases)
- [Commits](xunit/visualstudio.xunit@2.5.1...2.5.3)

---
updated-dependencies:
- dependency-name: xunit.runner.visualstudio
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants