@@ -6,8 +6,8 @@ Semi-automatic [SemVer2-compatible](https://semver.org/spec/v2.0.0.html)
66versioning for .NET and MSBuild.
77
88Features:
9- - Generates pre-release tags for Git branches, pull requests, and tags.
10- - Verifies that release tags match their code versions.
9+ - Generates SemVer2 versions from Git branches, pull requests, and tags.
10+ - Verifies that version-like Git tags match their code versions.
1111
1212## Status
1313
@@ -20,9 +20,8 @@ This package makes the following assumptions:
2020- .NET [ SDK-style] ( https://docs.microsoft.com/en-us/dotnet/core/project-sdk/overview )
2121 project system
2222- Git source control
23- - Releases marked with tags like ` release/1.2.3-rc.1 ` \
24- (the prefix ` release/ ` followed by a valid
25- [ SemVer2] ( https://semver.org/spec/v2.0.0.html ) version)
23+ - Releases marked with Git tags like ` v1.2.3 ` or ` release/1.2.3-rc.1 `
24+ (a configurable prefix followed by a valid [ SemVer2] ( https://semver.org/spec/v2.0.0.html ) version)
2625
2726## Usage
2827
4140
4241Set the version number in your project file or in a
4342[ ` Directory.Build.props ` ] ( https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build#directorybuildprops-and-directorybuildtargets )
44- file. Use the ` VersionPrefix ` property only.
43+ file. Use the ` VersionPrefix ` MSBuild property only.
4544
4645``` xml
4746<PropertyGroup >
@@ -50,27 +49,37 @@ file. Use the `VersionPrefix` property only.
5049```
5150
5251Pass the [ git refspec] ( https://git-scm.com/book/en/v2/Git-Internals-The-Refspec )
53- into the build process using the ` Branch ` property.
52+ into the build process using the ` Branch ` MSBuild property.
5453
5554``` shell
5655dotnet build -c Release -p:Branch=refs/heads/mybranch
5756```
5857
5958The build will generate a version like ` 1.2.3-mybranch.20201214.T154854Z ` and
60- set both the ` Version ` and ` VersionSuffix ` properties automatically. To use a
61- custom build number instead of the default date/time-based one, pass the number
62- to the build process using the ` Counter ` property.
59+ set both the ` Version ` and ` VersionSuffix ` MSBuild properties automatically.
60+ To use a custom build number instead of the default date/time-based one, pass
61+ the number to the build process using the ` Counter ` MSBuild property.
6362
6463``` shell
6564dotnet build -c Release -p:Branch=refs/heads/mybranch -p:Counter=4567
6665```
6766
6867The build will generate the version ` 1.2.3-mybranch.b.4567 ` .
6968
69+ To build a custom pre-release or a final release, use a version-like Git tag.
70+
71+ ``` shell
72+ dotnet build -c Release -p:Branch=refs/tags/release/1.2.3-beta -p:Counter=4567
73+ ```
74+
75+ The build will generate the version ` 1.2.3-beta ` . When the Git tag looks like
76+ a SemVer2 version, the build uses that version verbatim and does not append a
77+ timestamp or a build number.
78+
7079#### Interaction With Build Servers
7180
7281To communicate the generated version number to a build server, add one or
73- more of the following properties to one of your project files.
82+ more of the following MSBuild properties to one of your project files.
7483
7584``` xml
7685<PropertyGroup >
@@ -80,11 +89,32 @@ more of the following properties to one of your project files.
8089</PropertyGroup >
8190```
8291
92+ #### Custom Version-Like Tag Prefix
93+
94+ By default, this package expects version-like Git tags to have a ` release/ `
95+ prefix. To use a different prefix, override the ` VersionTagPrefix ` MSBuild
96+ property. This can be useful if you prefer the ` v ` prefix.
97+
98+ ``` xml
99+ <PropertyGroup >
100+ <VersionTagPrefix >v</VersionTagPrefix >
101+ </PropertyGroup >
102+ ```
103+
104+ A custom prefix is useful to disambiguate the version-like Git tags of
105+ unrelated subprojects in a monorepo.
106+
107+ ``` xml
108+ <PropertyGroup >
109+ <VersionTagPrefix >MyProject/v</VersionTagPrefix >
110+ </PropertyGroup >
111+ ```
112+
83113#### Version Stamping
84114
85115TODO
86116
87- ## Property Reference
117+ ## MSBuild Property Reference
88118
89119#### ` Branch `
90120The full [ git refspec] ( https://git-scm.com/book/en/v2/Git-Internals-The-Refspec )
@@ -93,29 +123,32 @@ the format of the refspec:
93123
94124- ` refs/heads/foo `
95125 - Recognized as a branch named ` foo ` .
96- - Sets the pre-release tag to ` foo ` followed by a build counter.
126+ - Sets the version suffix to ` foo ` followed by a build counter.
97127- ` refs/heads/foo/bar `
98128 - Recognized as a branch named ` foo/bar ` .
99- - Sets the pre-release tag to ` foo-bar ` followed by a build counter.
129+ - Sets the version suffix to ` foo-bar ` followed by a build counter.
100130- ` refs/pull/42 `
101131 - Recognized as pull request 42.
102- - Sets the pre-release tag to ` pr.42 ` followed by a build counter.
132+ - Sets the version suffix to ` pr.42 ` followed by a build counter.
103133- ` refs/tag/release/1.2.3-foo.42 `
104- - Recognized as a pre-release tag named ` release/1.2.3-foo.42 ` .
134+ - Recognized as a version-like Git tag with the pre-release version
135+ ` 1.2.3-foo.42 ` .
105136 - Emits a build error if the ` VersionPrefix ` property does not match
106137 the tag version, ` 1.2.3 ` .
107- - Sets the pre-release tag to ` foo.42 ` followed by a build counter.
138+ - Sets the version suffix to ` foo.42 ` followed by a build counter.
139+ - The ` release/ ` prefix is configurable.
108140- ` refs/tag/release/1.2.3 `
109- - Recognized as a release tag named ` release/ 1.2.3 ` .
141+ - Recognized as a version-like Git tag with the release version ` 1.2.3 ` .
110142 - Emits a build error if the ` VersionPrefix ` property does not match
111143 the tag version, ` 1.2.3 ` .
112- - ** Does not** set a pre-release tag or append a build counter.
144+ - ** Does not** set a version suffix or append a build counter.
145+ - The ` release/ ` prefix is configurable.
113146- ` something else entirely `
114147 - Not recognized.
115- - Sets the pre-release tag to ` something-else-entirely ` followed by a
148+ - Sets the version suffix to ` something-else-entirely ` followed by a
116149 build counter.
117150- empty or not set
118- - Sets the pre-release tag to ` local ` , without a build counter. This
151+ - Sets the version suffix to ` local ` , without a build counter. This
119152 default is intended to ease local development.
120153
121154#### ` Counter `
@@ -141,6 +174,10 @@ When `true`, the build outputs [magic text](https://www.jetbrains.com/help/teamc
141174that sets the [ build number] ( https://www.jetbrains.com/help/teamcity/build-number.html )
142175of the current TeamCity build.
143176
177+ #### ` VersionTagPrefix `
178+ The prefix that identifies a version-like Git tag. The default value is
179+ ` release/ ` .
180+
144181<!--
145182 Copyright Subatomix Research Inc.
146183 SPDX-License-Identifier: ISC
0 commit comments