question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] NullReferenceException during dotnet-gitversion execution

See original GitHub issue

This one is a show stopper for the library. During the build we are getting NullReferenceException

System.NullReferenceException: Object reference not set to an instance of an object.
   at GitVersion.GitObject..ctor(GitObject innerGitObject) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\GitObject.cs:line 12
   at GitVersion.Commit..ctor(Commit innerCommit) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\Commit.cs:line 15
   at GitVersion.GitRepository.<>c__DisplayClass27_0.<FindMergeBase>b__0() in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\GitRepository.cs:line 60
   at Polly.Policy`1.<>c__DisplayClass11_0.<Execute>b__0(Context ctx, CancellationToken ct)
   at Polly.Retry.RetryEngine.Implementation[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Action`4 onRetry, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider)
   at Polly.Retry.RetryPolicy`1.Implementation(Func`3 action, Context context, CancellationToken cancellationToken)
   at Polly.Policy`1.Execute(Func`3 action, Context context, CancellationToken cancellationToken)
   at Polly.Policy`1.Execute(Func`1 action)
   at GitVersion.Helpers.RetryAction`2.Execute(Func`1 operation) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Helpers\RetryAction.cs:line 42
   at GitVersion.GitRepository.FindMergeBase(ICommit commit, ICommit otherCommit) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\GitRepository.cs:line 58
   at GitVersion.RepositoryStore.FindMergeBase(IBranch branch, IBranch otherBranch) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\RepositoryStore.cs:line 46
   at GitVersion.RepositoryStore.<>c__DisplayClass29_0.<GetMergeCommitsForBranch>b__2(IBranch otherBranch) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\RepositoryStore.cs:line 466
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.ToArray()
   at System.Linq.OrderedEnumerable`1.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at GitVersion.RepositoryStore.GetMergeCommitsForBranch(IBranch branch, Config configuration, IEnumerable`1 excludedBranches) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\RepositoryStore.cs:line 450
   at GitVersion.RepositoryStore.FindCommitBranchWasBranchedFrom(IBranch branch, Config configuration, IBranch[] excludedBranches) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\RepositoryStore.cs:line 328
   at GitVersion.VersionCalculation.VersionInBranchNameVersionStrategy.GetVersions(String tagPrefixRegex, IBranch currentBranch)+MoveNext() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\BaseVersionCalculators\VersionInBranchNameVersionStrategy.cs:line 41
   at GitVersion.VersionCalculation.BaseVersionCalculator.GetBaseVersions(IVersionStrategy strategy)+MoveNext() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\BaseVersionCalculator.cs:line 90
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at GitVersion.VersionCalculation.BaseVersionCalculator.GetBaseVersion() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\BaseVersionCalculator.cs:line 31
   at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\VersionCalculation\NextVersionCalculator.cs:line 58
   at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 52
   at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 70
  INFO [06/17/21 19:06:23:48] Attempting to show the current git graph (please include in issue): 
  INFO [06/17/21 19:06:23:48] Showing max of 100 commits
  INFO [06/17/21 19:06:23:58] *   4cbc0d65 in the future  (HEAD -> release/5.12.0, origin/release/5.12.0)

Used GitVersion.TooL task when the problem first started, upgraded to GitVersion.MSBuild latest with no success. Switched to Actions in hope that will fix the issue, but it is all the same.

This is the link to failing build. To reproduce, just clone branch locally.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pavelmatejucommented, Mar 4, 2022

@asbjornu ,

Yes you are right. My bad. This is another bug. Thank you !

As soon as you specified correct value or even some value you get expected result.

1reaction
asbjornucommented, Mar 3, 2022

@pavelmateju, your problem is that the /output argument is missing a value. It failing with a NullReferenceException is a bug, but if you add /output json it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug] Null Exception · Issue #2825 · GitTools/GitVersion
Describe the bug Error: The process '/opt/hostedtoolcache/GitVersion.Tool/5.7.0/x64/dotnet-gitversion' failed with exit code 1 Expected Behavior output JSON ...
Read more >
Azure DevOps pipeline task `task: gitversion/execute@0` ...
But the execute task in the new pipeline fails with an 'unexpected' error steps: - task: gitversion/setup@0 displayName: Install GitVersion ...
Read more >
Configuration
Configuration. GitVersion, starting from version 3.0, is mainly powered by configuration and no longer has branching strategies hard-coded.
Read more >
Azure DevOps
In Azure DevOps Pipeline (the web based build system) you can call GitVersion either using the Command Line build step or install an...
Read more >
How to use GitVersion to get sensible versioning
NET assemblies, NuGet packages and NPM packages. I particularly like the InformationalVersion which even includes the git hash of the commit ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found