MinVer 3.0.0-rc.2
See the version list below for details.
dotnet add package MinVer --version 3.0.0-rc.2
NuGet\Install-Package MinVer -Version 3.0.0-rc.2
<PackageReference Include="MinVer" Version="3.0.0-rc.2"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add MinVer --version 3.0.0-rc.2
#r "nuget: MinVer, 3.0.0-rc.2"
// Install MinVer as a Cake Addin #addin nuget:?package=MinVer&version=3.0.0-rc.2&prerelease // Install MinVer as a Cake Tool #tool nuget:?package=MinVer&version=3.0.0-rc.2&prerelease
MinVer
A minimalist .NET package for versioning .NET SDK-style projects using Git tags.
Platform support: all platforms supported by .NET SDK-style projects.
Also available as a command-line tool for use in any Git repository.
Prerequisites
Quick start
- Install MinVer.
- Build your project.
Your project will be versioned according to the latest tag found in the commit history.
To build with GitHub Actions, set the fetch depth appropriately.
Usage
When you want to release a version of your software, whether it's a pre-release, RTM, patch, or anything else, simply create a tag with a name which is a valid SemVer 2.x version and build your projects. MinVer will apply the version to the assemblies and packages. (If you like to prefix your tag names, see the FAQ.)
NOTE: The MinVer package reference should normally include PrivateAssets="All"
. See NuGet docs for more info. If you install MinVer using an IDE or tool, this should be done for you automatically.
How it works
- If the current commit has a version tag:
- The version is used as-is.
- If the current commit does not have a version tag:
- The commit history is searched for the latest commit with a version tag.
- If a commit with a version tag is found:
- If the version is a pre-release:
- The version is used as-is, with height added.
- If the version is RTM (not pre-release):
- The patch number is incremented, but this can be customised.
- Default pre-release identifiers are added. The default pre-release phase is "alpha", but this can be customised.
- For example, if the latest version tag is
1.0.0
, the current version is1.0.1-alpha.0
. - Height is added.
- If the version is a pre-release:
- If no commit with a version tag is found:
- The default version
0.0.0-alpha.0
is used, with height added.
- The default version
- If a commit with a version tag is found:
- The commit history is searched for the latest commit with a version tag.
Height
If the current commit does not have a version tag, another number is added to the pre-release identifiers. This is the number of commits since the latest commit with a version tag or, if no commits have a version tag, since the root commit. This is known as "height". For example, if the latest version tag found is 1.0.0-beta.1
, at a height of 42 commits, the calculated version is 1.0.0-beta.1.42
.
Version numbers
MinVer sets the following custom properties:
MinVerVersion
MinVerMajor
MinVerMinor
MinVerPatch
MinVerPreRelease
MinVerBuildMetadata
Those properties are used to set the following .NET SDK properties, satisfying the official open-source library guidance for version numbers:
Property | Value |
---|---|
AssemblyVersion |
{MinVerMajor}.0.0.0 |
FileVersion |
{MinVerMajor}.{MinVerMinor}.{MinVerPatch}.0 |
PackageVersion |
{MinVerVersion} |
Version |
{MinVerVersion} |
This behaviour can be customised.
Options
Options may be specified as either MSBuild properties (for the MinVer package) or environment variables (for both the MinVer and minver-cli packages).
MinVerAutoIncrement
MinVerBuildMetadata
MinVerDefaultPreReleasePhase
MinVerMinimumMajorMinor
MinVerSkip
MinVerTagPrefix
MinVerVerbosity
MinVerVersionOverride
Note that the option names are case-insensitive.
FAQ
(With TL;DR answers inline.)
- Why not use GitVersion, Nerdbank.GitVersioning, or some other tool? (simplicity)
- Can I bump the major or minor version? (yes)
- Can I use my own pre-release versioning scheme? (yes)
- Can I prefix my tag names? (yes)
- Can I use my own branching strategy? (yes)
- Can I include build metadata in the version? (yes)
- Can I auto-increment the minor or major version after an RTM tag instead of the patch version? (yes)
- Can I change the default pre-release phase from "alpha" to something else? (yes)
- Can I use the version calculated by MinVer for other purposes? (yes)
- Can I version multiple projects in a single repository independently? (yes)
- Can I get log output to see how MinVer calculates the version? (yes)
- Can I use MinVer to version software which is not built using a .NET SDK style project? (yes)
- Can I disable MinVer? (yes)
- What if the history diverges, and more than one tag or root commit is found? (nothing bad)
- What if the history diverges, and then converges again, before the latest tag (or root commit) is found? (nothing bad)
- Why is the default version sometimes used in GitHub Actions and Travis CI when a version tag exists in the history? (shallow clones)
Why not use GitVersion, Nerdbank.GitVersioning, or some other tool?
Before starting MinVer, Adam Ralph evaluated both GitVersion and Nerdbank.GitVersioning, but neither of them worked in the way he wanted for his projects.
The TL;DR is that MinVer is simpler. "How it works" pretty much captures everything.
Comparison with GitVersion
To some degree, MinVer is a subset of what GitVersion is. It's much simpler and doesn't do nearly as much. Some of the differences:
- No dependency on a specific branching pattern.
- No inference of version from branch names.
- No inference of version from YAML config.
- No inference of version from commit messages.
- No inference of version from CI build server environment variables.
- No creation of metadata code artifacts.
- No automatic fetching of tags, etc. from the repository.
- One package instead of a series of packages.
- No support for
AssemblyInfo.cs
.
Comparison with Nerdbank.GitVersioning
MinVer is a different approach and, again, simpler. Some of the differences are already listed under the comparison with GitVersion above.
Essentially, Nerdbank.GitVersioning encapsulates the injection of the version into the build process from a config file. That means versions are controlled by commits to that config file. MinVer works purely on tags. That means MinVer doesn't need some of the types of things that come with Nerdbank.GitVersioning such as the config file bootstrapper, and it means the version is controlled independently of the commits. For example, you can tag a commit as a release candidate, build it, and release it. After some time, if the release candidate has no bugs, you can tag the same commit as RTM, build it, and release it.
Also, Nerdbank.GitVersioning uses the git height for the patch version, which is undesirable. Either every patch commit has to be released, or there will be gaps in the patch versions released.
Can I bump the major or minor version?
Yes! You probably want to do this because at a point in time, on a given branch, you are working on a specific MAJOR.MINOR
range, e.g. 1.0
, 1.1
, or 2.0
. The branch could be main
, develop
, a special release branch, a support branch, or anything else.
Before you create the first version tag on your branch, interim builds will use the latest version tag found in the commit history, which may not match the MAJOR.MINOR
range you are working on. Or if no version tag is found in the commit history, interim builds will have the default version 0.0.0-alpha.0
. If you prefer those interim builds to have a version in the range you are working on, you have two options:
Tag a commit
Tag a commit in your branch with a version matching your MAJOR.MINOR
range, using your preferred default pre-release phase and a pre-release ordinal of 0. For example:
git tag 1.0.0-alpha.0
This is not a version you will release, since the first "alpha" version will be 1.0.0-alpha.1
. The only purpose of this tag is to force MinVer to start versioning commits in your branch in the 1.0
range.
If you begin to release versions in the 1.0
range from another branch (e.g. a special release branch), tag a commit in your branch with 1.1.0-alpha.0
, 2.0.0-alpha.0
, or whatever MAJOR.MINOR
range your branch now represents.
Set MinVerMinimumMajorMinor
Specify your range with MinVerMinimumMajorMinor
. For example:
<PropertyGroup>
<MinVerMinimumMajorMinor>1.0</MinVerMinimumMajorMinor>
</PropertyGroup>
MinVer will now use a default version of 1.0.0-alpha.0
.
If you begin to release versions in the 1.0
range from another branch (e.g. a special release branch), set MinVerMinimumMajorMinor to 1.1
, 2.0
, or whatever MAJOR.MINOR
range your branch now represents.
Note that MinVerMinimumMajorMinor
will be redundant after you create the first tag in your branch with same MAJOR.MINOR
. If you don't care that the versions of interim builds before that first tag will have a lower MAJOR.MINOR
, then simply don't specify MinVerMinimumMajorMinor
.
Also note that if the latest version tag found in the commit history has a higher MAJOR.MINOR
than MinVerMinimumMajorMinor
, then MinVerMinimumMajorMinor
will be ignored.
Can I use my own pre-release versioning scheme?
Yes! MinVer doesn't care what your pre-release versioning scheme is. The default pre-release identifiers are alpha.0
, but you can use whatever you like in your tags. If your versioning scheme is valid SemVer 2.x, it will work with MinVer.
For example, all these versions work with MinVer:
1.0.0-beta.1
1.0.0-pre.1
1.0.0-preview-20181104
1.0.0-rc.1
Can I prefix my tag names?
Yes! Specify the prefix with MinVerTagPrefix
.
For example, if you prefix your tag names with "v", e.g. v1.2.3
:
<PropertyGroup>
<MinVerTagPrefix>v</MinVerTagPrefix>
</PropertyGroup>
Can I use my own branching strategy?
Yes! MinVer doesn't care about branches. It's all about the tags!
That means MinVer is compatible with Git Flow, GitHub Flow, Release Flow, and any other exotic flow.
Can I include build metadata in the version?
Yes! Specify build metadata with MinVerBuildMetadata
.
For example, in appveyor.yml
:
environment:
MINVERBUILDMETADATA: build.%APPVEYOR_BUILD_NUMBER%
You can also specify build metadata in a version tag. If the tag is on the current commit, its build metadata will be used. If the tag is on an older commit, its build metadata will be ignored. Build metadata in MinVerBuildMetadata
will be appended to build metadata in the tag.
Can I auto-increment the minor or major version after an RTM tag instead of the patch version?
Yes! Specify which part of the version to auto-increment with MinVerAutoIncrement
. By default, MinVer will auto-increment the patch version, but you can specify minor
or major
to increment the minor or major version instead.
Can I change the default pre-release phase from "alpha" to something else?
Yes! Specify the default pre-release phase with MinVerDefaultPreReleasePhase
. For example, if you prefer to name your pre-releases as "preview":
<PropertyGroup>
<MinVerDefaultPreReleasePhase>preview</MinVerDefaultPreReleasePhase>
</PropertyGroup>
This will result in a post-RTM version of {major}.{minor}.{patch+1}-preview.{height}
, e.g. 1.0.1-preview.1
.
Can I use the version calculated by MinVer for other purposes?
Yes! You can use any of the properties set by MinVer, or override their values, in a target which runs after MinVer.
For example, for pull requests, you may want to inject the pull request number and a variable which uniquely identifies the build into the version. E.g. using Appveyor:
<Target Name="MyTarget" AfterTargets="MinVer" Condition="'$(APPVEYOR_PULL_REQUEST_NUMBER)' != ''" >
<PropertyGroup>
<PackageVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch)-pr.$(APPVEYOR_PULL_REQUEST_NUMBER).build-id.$(APPVEYOR_BUILD_ID).$(MinVerPreRelease)</PackageVersion>
<PackageVersion Condition="'$(MinVerBuildMetadata)' != ''">$(PackageVersion)+$(MinVerBuildMetadata)</PackageVersion>
<Version>$(PackageVersion)</Version>
</PropertyGroup>
</Target>
Or for projects which do not create NuGet packages, you may want to populate all four parts of AssemblyVersion
. E.g. using Appveyor:
<Target Name="MyTarget" AfterTargets="MinVer">
<PropertyGroup>
<APPVEYOR_BUILD_NUMBER Condition="'$(APPVEYOR_BUILD_NUMBER)' == ''">0</APPVEYOR_BUILD_NUMBER>
<AssemblyVersion>$(MinVerMajor).$(MinVerMinor).$(APPVEYOR_BUILD_NUMBER).$(MinVerPatch)</AssemblyVersion>
</PropertyGroup>
</Target>
Or for projects which do create NuGet packages, you may want to adjust the assembly file version to include the build number, as recommended in the official guidance. E.g. when using Appveyor:
<Target Name="MyTarget" AfterTargets="MinVer">
<PropertyGroup>
<APPVEYOR_BUILD_NUMBER Condition="'$(APPVEYOR_BUILD_NUMBER)' == ''">0</APPVEYOR_BUILD_NUMBER>
<FileVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch).$(APPVEYOR_BUILD_NUMBER)</FileVersion>
</PropertyGroup>
</Target>
Can I version multiple projects in a single repository independently?
Yes! You can do this by using a specific tag prefix for each project. For example, if you have a "main" project and an "extension" project, you could specify <MinVerTagPrefix>main-</MinVerTagPrefix>
in the main project and <MinVerTagPrefix>ext-</MinVerTagPrefix>
in the extension project. To release version 1.0.0
of the main project you'd tag the repository with main-1.0.0
. To release version 1.1.0
of the extension project you'd tag the repository with ext-1.1.0
.
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
. These verbosity levels match those in MSBuild and therefore dotnet build
, dotnet pack
, etc. The default is minimal
, which matches the default in MSBuild. At the quiet
and minimal
levels, you will see only warnings and errors. At the normal
level you will see which commit is being used to calculate the version, and the calculated version. At the detailed
level you will see how many commits were examined, which version tags were found but ignored, which version was calculated, etc. At the diagnostic
level you will see how MinVer walks the commit history, in excruciating detail.
In a future version of MinVer, the verbosity level may be inherited from MSBuild, in which case MinVerVerbosity
will be deprecated.
Can I use MinVer to version software which is not built using a .NET SDK style project?
Yes! MinVer is also available as a command-line tool. Run minver --help
for usage. The calculated version is printed to standard output (stdout).
Sometimes you may want to version both .NET projects and other outputs, such as non-.NET projects, or a container image, in the same build. In those scenarios, you should use both the command-line tool and the regular MinVer package. Before building any .NET projects, your build script should run the command-line tool and set the MINVERVERSIONOVERRIDE
environment variable to the calculated version. The MinVer package will then use that value rather than calculating the version a second time. This ensures that the command-line tool and the MinVer package produce the same version.
If the components of the version are required outside the context of a .NET project, they can easily be extracted from the version which is returned by the command-line tool. The major, minor, and patch numbers can be separated from the pre-release identifiers by splitting the version by the first instance of -
. The major, minor, and patch numbers and the pre-release identifiers can then be separated by splitting by .
.
Can I disable MinVer?
Yes! Set MinVerSkip
to true
. For example, MinVer can be disabled for debug builds:
<PropertyGroup>
<MinVerSkip Condition="'$(Configuration)' == 'Debug'">true</MinVerSkip>
</PropertyGroup>
What if the history diverges, and more than one tag or root commit is found?
MinVer will use the tag with the higher version, or the tag or root commit 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.
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.
Why is the default version sometimes used in GitHub Actions and Travis CI when a version tag exists in the history?
By default, GitHub Actions and Travis CI use shallow clones. The GitHub Actions checkout action clones with a depth of only a single commit, and Travis CI clones with a depth of 50 commits. In GitHub Actions, if the latest version tag in the history is not on the current commit, it will not be found. In Travis CI, if the latest version tag in the history is at a height of more than 50 commits, it will not be found.
To build in GitHub Actions or Travis CI, configure them to fetch a sufficient number of commits.
For GitHub Actions, set the fetch-depth
of the checkout action to an appropriate number, or to zero for all commits. For example:
- uses: actions/checkout@v2
with:
fetch-depth: 0
For Travis CI, set the --depth
flag to an appropriate number, or to false
for all commits:
git:
depth: false
<sub>Tag by Ananth from the Noun Project.</sub>
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages (45)
Showing the top 5 NuGet packages that depend on MinVer:
Package | Downloads |
---|---|
BlazorAnimate
Easily Animate Blazor Components using Blazor Animate. Powered by AOS. |
|
EventAggregator.Blazor
Lightweight Event Aggregator for Blazor. |
|
Particular.Packaging
NuGet packaging for Particular repositories |
|
HumanBytes
A library to convert byte sizes to a human readable form. |
|
SerilogEventLogger
Package Description |
GitHub repositories (159)
Showing the top 5 popular GitHub repositories that depend on MinVer:
Repository | Stars |
---|---|
App-vNext/Polly
Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. From version 6.0.1, Polly targets .NET Standard 1.1 and 2.0+.
|
|
jbogard/MediatR
Simple, unambitious mediator implementation in .NET
|
|
AutoMapper/AutoMapper
A convention-based object-object mapper in .NET.
|
|
restsharp/RestSharp
Simple REST and HTTP API Client for .NET
|
|
spectreconsole/spectre.console
A .NET library that makes it easier to create beautiful console applications.
|
Version | Downloads | Last updated |
---|---|---|
6.0.0 | 183,305 | 9/4/2024 |
6.0.0-rc.1 | 667 | 8/15/2024 |
5.1.0-rc.1 | 79 | 8/15/2024 |
5.0.0 | 731,974 | 3/4/2024 |
5.0.0-beta.1 | 11,115 | 10/18/2023 |
5.0.0-alpha.1 | 5,089 | 6/9/2023 |
4.3.0 | 1,357,467 | 1/27/2023 |
4.3.0-beta.1 | 1,635 | 11/24/2022 |
4.2.0 | 963,706 | 8/22/2022 |
4.2.0-rc.1 | 3,094 | 7/25/2022 |
4.2.0-alpha.1 | 196 | 7/24/2022 |
4.1.0 | 244,408 | 6/27/2022 |
4.1.0-rc.1 | 397 | 6/9/2022 |
4.1.0-alpha.2 | 627 | 5/27/2022 |
4.1.0-alpha.1 | 219 | 5/24/2022 |
4.0.0 | 93,432 | 5/15/2022 |
4.0.0-rc.1 | 692 | 5/4/2022 |
4.0.0-alpha.1 | 712 | 4/3/2022 |
3.1.0 | 165,122 | 3/19/2022 |
3.1.0-beta.1 | 612 | 3/12/2022 |
3.0.0 | 65,023 | 3/12/2022 |
3.0.0-rc.3 | 372 | 3/8/2022 |
3.0.0-rc.2 | 764 | 3/5/2022 |
3.0.0-rc.1 | 2,067 | 12/23/2021 |
3.0.0-alpha.1 | 16,600 | 8/22/2021 |
2.5.0 | 1,221,786 | 3/13/2021 |
2.5.0-rc.1 | 944 | 2/7/2021 |
2.5.0-alpha.1 | 270 | 1/18/2021 |
2.4.0 | 159,140 | 12/22/2020 |
2.4.0-beta.2 | 495 | 12/21/2020 |
2.4.0-beta.1 | 264 | 12/21/2020 |
2.3.1 | 466,960 | 9/26/2020 |
2.3.1-beta.2 | 454 | 9/14/2020 |
2.3.1-beta.1 | 300 | 9/14/2020 |
2.3.0 | 528,925 | 5/26/2020 |
2.2.0 | 346,347 | 3/7/2020 |
2.1.0 | 15,111 | 2/9/2020 |
2.1.0-rc.1 | 969 | 12/22/2019 |
2.0.0 | 479,681 | 10/13/2019 |
2.0.0-rc.1 | 3,351 | 9/25/2019 |
2.0.0-alpha.2 | 1,145 | 9/14/2019 |
2.0.0-alpha.1 | 401 | 9/14/2019 |
1.2.0 | 9,320 | 8/15/2019 |
1.2.0-rc.1 | 2,267 | 8/6/2019 |
1.2.0-beta.1 | 515 | 8/3/2019 |
1.1.0 | 39,269 | 5/23/2019 |
1.1.0-rc.1 | 438 | 5/19/2019 |
1.1.0-beta.2 | 1,184 | 4/12/2019 |
1.1.0-beta.1 | 314 | 4/12/2019 |
1.0.0 | 24,999 | 3/9/2019 |
1.0.0-rc.1 | 2,026 | 2/21/2019 |
1.0.0-beta.4 | 3,668 | 1/6/2019 |
1.0.0-beta.3 | 1,377 | 1/1/2019 |
1.0.0-beta.2 | 5,217 | 12/20/2018 |
1.0.0-beta.1 | 6,975 | 11/27/2018 |
1.0.0-alpha.21 | 899 | 11/26/2018 |
1.0.0-alpha.20 | 434 | 11/25/2018 |
1.0.0-alpha.19 | 401 | 11/25/2018 |
1.0.0-alpha.18 | 423 | 11/23/2018 |
1.0.0-alpha.17 | 445 | 11/23/2018 |
1.0.0-alpha.16 | 460 | 11/22/2018 |
1.0.0-alpha.15 | 742 | 11/19/2018 |
1.0.0-alpha.14 | 417 | 11/6/2018 |
1.0.0-alpha.13 | 560 | 11/5/2018 |
1.0.0-alpha.12 | 451 | 11/3/2018 |
1.0.0-alpha.11 | 433 | 11/3/2018 |
1.0.0-alpha.10 | 429 | 11/2/2018 |
1.0.0-alpha.9 | 399 | 10/31/2018 |
1.0.0-alpha.8 | 418 | 10/31/2018 |
1.0.0-alpha.7 | 418 | 10/30/2018 |
1.0.0-alpha.6 | 422 | 10/29/2018 |
1.0.0-alpha.5 | 397 | 10/28/2018 |
1.0.0-alpha.4 | 458 | 10/28/2018 |
1.0.0-alpha.3 | 422 | 10/28/2018 |
1.0.0-alpha.2 | 437 | 10/27/2018 |
1.0.0-alpha.1 | 440 | 10/27/2018 |