Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS 2013 Throws Lib2GitSharp Error During Build/Deploy (Intermittent)

Tags:

c#

.net

tfs

For a while now, I have been having an issue with Team Foundation Server build/deploy process throwing the following error intermittently:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at LibGit2Sharp.Core.NativeMethods.git_threads_init()
at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject..ctor()
at LibGit2Sharp.Core.NativeMethods..cctor()
--- End of inner exception stack trace ---
at LibGit2Sharp.Core.NativeMethods.RemoveHandle()
at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject.Finalize()
Exception Message: MSBuild error 255 has ended this build. You can find more     specific information about the cause of this error in above messages. (type   BuildProcessTerminateException) Exception Stack Trace: at     System.Activities.Statements.Throw.Execute(CodeActivityContext context) at     System.Activities.CodeActivity.InternalExecute(ActivityInstance instance,     ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

This problem is very intermittent and it can be bypassed by simply retrying the build. Has anyone else run into this? Any solutions?

like image 478
Ryan Mendoza Avatar asked Mar 26 '15 18:03

Ryan Mendoza


2 Answers

I know it is a little bit late for answer but it might help someone else

answer by Buck Hodges

We have now gotten to the bottom of this issue after debugging it with Manoj and customer support. It affected gated checkin of continuous delivery of Azure deployments as part of the build process when using the Azure SDK 2.5 or older. The workaround is to add /p:GenerateBuildInfoConfigFile=false to the msbuild arguments in your build definition. We are working on updating the build VM in production, but that will take 24-48 hours to propagate to all build pools.

Adding msbuild argument

You might want to read more in context here https://social.msdn.microsoft.com/Forums/en-US/5a0d1950-1367-41a6-9171-676a0d0e93c1/tfs-online-getted-checkin-build-failures-vs-online-tfs-online-team-need-to-look-into-it?forum=TFService

Alternative solution based on comments

If you have VS installed on your build server, make sure you have opened it and licensed it. by @Phill

like image 142
cpoDesign Avatar answered Nov 16 '22 14:11

cpoDesign


Strangely enough for me, I was getting the same error in the build logs:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\BuildInfo\Microsoft.VisualStudio.ReleaseManagement.BuildInfo.targets (147): The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. Unhandled Exception: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

I was able to simply RETRY the build, and it did not fail on the second try. So for me it was a transitory build issue.

like image 25
jbooker Avatar answered Nov 16 '22 15:11

jbooker