Customize version suffix MinVer

1.1k Views Asked by At

I'm using MinVer and can't find how to get the commit height to create a custom version suffix. Ideally I would like to have 1.0.0-preview.{commits} instead of 1.0.0.-preview.0.{commits}. What the zero between the pre-release label and commit height is I don't know. (Yes, I've set <MinVerDefaultPreReleasePhase> to preview :))

Secondly, using GitInfo I notice a discrepancy in the number of commits. Below is output from some me experimenting on github

$ dotnet Application.dll
========== Git ==========
Commit     a54e9e9
Commit SHA a54e9e96868470ebf13d4a35ce9858c09a534363
Branch     remotes/origin/master
Tag
Commits    39
========== Assembly ==========
Version              1.0.0
Assembly             Not found: AssemblyVersionAttribute
Informational        1.0.0-preview.0.34+a54e9e96868470ebf13d4a35ce9858c09a534363
File                 1.0.0.24 // AzDo BuildId=24

Diagnosing MinVer gives me some hints about a root commit, but I know to little about git what determines the root commit.

MinVer: Starting at commit a54e9e9 (height 0)...
  MinVer: History diverges from 3c0633f (height 20) to:
  MinVer: - 56af0a5 (height 21)
  MinVer: - 747ef5a (height 21)
  MinVer: Following path from 3c0633f (height 20) through first parent 56af0a5 (height 21)...
  MinVer: Found root commit { Commit: faa505b, Tag: null, Version: 0.0.0-preview.0, Height: 34 }.
  MinVer: Backtracking to 3c0633f (height 20) and following path through last parent 747ef5a (height 21)...
  MinVer: History converges from 0f35453 (height 24) back to previously seen commit 8dc52dc (height 25). Abandoning path.
  MinVer: 39 commits checked.
  MinVer: No commit found with a valid SemVer 2.0 version prefixed with ''. Using default version 0.0.0-preview.0.
  MinVer: Using { Commit: faa505b, Tag: null, Version: 0.0.0-preview.0, Height: 34 }.

So, to summarize:

  1. How do I customize version suffix for MinVer?
  2. What does the zero {MinVerDefaultPreReleasePhase}.0.{commits} represent?
  3. How is the commit height calculated/determined?

Third question leads me into versioning of NuGet and the section about FileVersionAssembly specifically the Revision-part of version number. But I leave this for another question.

Note I tried to add the tag minver but couldn't due to low reputation :)

Thanks

Joakim

1

There are 1 best solutions below

4
On BEST ANSWER
  1. How do I customize version suffix for MinVer?

I assume that "version suffix" refers to the pre-release identifiers. You can't customise all of them, only the default pre-release phase, which you are already doing with MinVerDefaultPreReleasePhase.


  1. What does the zero {MinVerDefaultPreReleasePhase}.0.{commits} represent?

It's a sentinel value that represents interim versions before the next version is released. Bear in mind that a fundamental assumption in MinVer is that you label before release, so you will never release one of these versions. E.g. the current commit may be building 0.0.0-preview.0.34. When you want to release your first preview, you'd tag the commit with 1.0.0-preview.1 and MinVer will embed that version into your assemblies and package.


  1. How is the commit height calculated/determined?

This is explained in "How it works":

You will notice that MinVer adds another number to the pre-release identifiers when the current commit is not tagged. This is the number of commits since the latest tag, or if no tag was found, since the root commit. This is known as "height". For example, if the latest tag found is 1.0.0-beta.1, at a height of 42 commits, the calculated version is 1.0.0-beta.1.42.

and from the FAQ:

What if the history diverges, and then converges again, before the latest tag (or root commit) is found?

MinVer will use the height on the first path followed where the history diverges. The paths are followed in the same order that the parents of the commit are stored in git. The first parent is the commit on the branch that was the current branch when the merge was performed. The remaining parents are stored in the order that their branches were specified in the merge command.

You can also see, in excruciating detail, how MinVer walks the history:

Can I get log output to see how MinVer calculates the version?

Yes! MinVerVerbosity can be set to quiet, minimal (default), normal, detailed, or diagnostic.

At the diagnostic level you will see how MinVer walks the commit history, in excruciating detail.