Skip to content

Commit 5248a4c

Browse files
committed
re-fixed the release handling (it was correct)
Updated docs so that is easier to understand what is needed to trigger areal release build number.
1 parent d3a93b6 commit 5248a4c

File tree

3 files changed

+54
-13
lines changed

3 files changed

+54
-13
lines changed

Directory.Build.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848

4949
<IsReleaseBuild Condition="'$(IsReleaseBuild)'=='' AND '$(APPVEYOR_REPO_TAG)'=='true' AND '$(APPVEYOR_PULL_REQUEST_NUMBER)'=='' AND '$(APPVEYOR_BRANCH)'=='master'">true</IsReleaseBuild>
5050
<IsReleaseBuild Condition="'$(IsReleaseBuild)'==''">false</IsReleaseBuild>
51-
<BuildVersionXml>$(MSBuildThisFileDirectory)BuildVersion.xml</BuildVersionXml>
5251
<BuildTime Condition="'$(BuildTime)'=='' AND '$(APPVEYOR_REPO_COMMIT_TIMESTAMP)'!=''">$(APPVEYOR_REPO_COMMIT_TIMESTAMP)</BuildTime>
5352
<!--
5453
Force the time-stamp into ISO 8601 format so it is locale neutral

README.md

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ Automated Constrained Semantic Versioning for MSBuild projects
66

77

88
## Overview
9-
NUGET Packages use a SemVer 2.0 (see http://semver.org)
10-
9+
Officially, NUGET Packages use a SemVer 2.0 (see http://semver.org).
1110
However, SemVer 2.0 doesn't consider or account for publicly available CI builds.
1211
SemVer is only concerned with official releases. This makes CI builds producing
1312
versioned packages challenging. Fortunately, someone has already defined a solution
@@ -57,6 +56,52 @@ The Major, Minor and Patch versions are only updated in the master branch at the
5756
of a release. This ensures the concept that SemVer versions define released products. The
5857
version numbers used are stored in the repository in the BuildVersion.xml
5958

59+
## Properties used to determine the version
60+
CSemVer.Build uses MSBuild properties to determine the final version number.
61+
62+
|Name |Default Value | Description|
63+
|-------------------|--------------------------------------------------------------|------------|
64+
| BuildMajor | Read from BuildVersion.xml | Major portion of the build number |
65+
| BuildMinor | Read from BuildVersion.xml | Minor portion of the build number |
66+
| BuildPatch | Read from BuildVersion.xml | Patch portion of the build number |
67+
| PreReleaseName | `<Undefined>` or value read from BuildVersion.xml if present | PreRelease Name of the CSemVer |
68+
| PreReleaseNumber | `<Undefined>` or value read from BuildVersion.xml if present | PreRelease Number of the CSemVer |
69+
| PreReleaseFix | `<Undefined>` or value read from BuildVersion.xml if present | PreRelease Fix of the CSemVer |
70+
| BuildMeta | `<undefined>` | Build meta for the version
71+
| CiBuildName | `<see notes>` | CSemVer CI name
72+
| CiBuildIndex | ISO 8601 formated UTC time-stamp for the build | Provides a unique build to build value guaranteed to increase with each build
73+
74+
### CiBuildName
75+
Unless explicitly provided, the CiBuildName is determined by a set of properties that indicate the nature of the
76+
build. The properties used (in evaluation order) are:
77+
78+
|Name |Default Value |CiBuildName | Description|
79+
|-------------------|---------------|---------------|------------|
80+
|IsPullRequestBuild | `<Undefined>` |`PRQ` if true | Used to indicate if the build is from a pull request |
81+
|IsAutomatedBuild | `<Undefined>` |`BLD` if true | Used to indicate if the build is an automated build |
82+
|IsReleaseBuild | `<Undefined>` |`ZZZ` if !true | Used to indicate if the build is an official release build |
83+
84+
These three values are determined by the automated build in some form. These are either explicit variables set for
85+
the build definition or determined on the fly based on values set by the build. Commonly a `directory.build.props`
86+
for a repository will specify these. The following is an example for setting them based on an AppVeyor build in
87+
the `Directory.Build.props` file:
88+
89+
```xml
90+
<PropertyGroup>
91+
<!-- If running in APPVEYOR it is an automated build -->
92+
<IsAutomatedBuild Condition="'$(IsAutomatedBuild)'=='' AND '$(APPVEYOR)'!=''">true</IsAutomatedBuild>
93+
<IsAutomatedBuild Condition="'$(IsAutomatedBuild)'==''">false</IsAutomatedBuild>
94+
95+
<!-- If it has a PR number associated it is a PR build -->
96+
<IsPullRequestBuild Condition="'$(IsPullRequestBuild)'=='' AND '$(APPVEYOR_PULL_REQUEST_NUMBER)'!=''">true</IsPullRequestBuild>
97+
<IsPullRequestBuild Condition="'$(IsPullRequestBuild)'==''">false</IsPullRequestBuild>
98+
99+
<!-- Tags applied to the master branch without a PR are release builds -->
100+
<IsReleaseBuild Condition="'$(IsReleaseBuild)'=='' AND '$(APPVEYOR_REPO_TAG)'=='true' AND '$(APPVEYOR_PULL_REQUEST_NUMBER)'=='' AND '$(APPVEYOR_BRANCH)'=='master'">true</IsReleaseBuild>
101+
<IsReleaseBuild Condition="'$(IsReleaseBuild)'==''">false</IsReleaseBuild>
102+
</PropertyGroup>
103+
```
104+
60105
## Building the tasks
61-
The tasks are pure C# so building the package simply involves simply building the
106+
The tasks are pure C# so building the package simply involves building the
62107
src\CSemVer.Build.Tasks.sln

src/CSemVer.Build.Tasks/CreateVersionInfo.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,12 @@ public class CreateVersionInfo
5151
public override bool Execute( )
5252
{
5353
PrereleaseVersion preReleaseVersion = null;
54-
if( !string.IsNullOrWhiteSpace( CiBuildName ) )
55-
{
56-
preReleaseVersion = new PrereleaseVersion( PreReleaseName
57-
, string.IsNullOrWhiteSpace( PreReleaseNumber ) ? 0 : Convert.ToInt32( PreReleaseNumber )
58-
, string.IsNullOrWhiteSpace( PreReleaseFix ) ? 0 : Convert.ToInt32( PreReleaseFix )
59-
, CiBuildName
60-
, CiBuildIndex
61-
);
62-
}
54+
preReleaseVersion = new PrereleaseVersion( PreReleaseName
55+
, string.IsNullOrWhiteSpace( PreReleaseNumber ) ? 0 : Convert.ToInt32( PreReleaseNumber )
56+
, string.IsNullOrWhiteSpace( PreReleaseFix ) ? 0 : Convert.ToInt32( PreReleaseFix )
57+
, CiBuildName
58+
, CiBuildIndex
59+
);
6360

6461
var fullVersion = new CSemVer( Convert.ToInt32( BuildMajor )
6562
, Convert.ToInt32( BuildMinor )

0 commit comments

Comments
 (0)