Skip to content

Commit

Permalink
Update how BuildNumbers are calculated (#2125)
Browse files Browse the repository at this point in the history
* Update _GlobalStaticVersion.props

Change to the way we calculate the build number.

Formerly, we calculated builds as the TotalMinutes between DateTime.Now and the semantic version time stamp, divided by 5.
This meant that every 5 minutes the build number changes.
This was hurting nightly nupkgs because our assembly version and packages weren't matching.

This PR changes the calculation to be TotalHours / 12.

* Update release_NupkgAudit.ps1
  • Loading branch information
TimothyMothra committed Dec 11, 2020
1 parent 854f6b5 commit 8629b7a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions .props/_GlobalStaticVersion.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
Update for every public release.
-->
<SemanticVersionMajor>2</SemanticVersionMajor>
<SemanticVersionMinor>16</SemanticVersionMinor> <!-- If changing the Minor version, also update the Date value. -->
<SemanticVersionMinor>17</SemanticVersionMinor> <!-- If changing the Minor version, also update the Date value. -->
<SemanticVersionPatch>0</SemanticVersionPatch>
<PreReleaseMilestone></PreReleaseMilestone> <!--Valid values: beta1, beta2, EMPTY for stable -->
<PreReleaseMilestone>beta1</PreReleaseMilestone> <!--Valid values: beta1, beta2, EMPTY for stable -->
<PreReleaseMilestone Condition="'$(NightlyBuild)' == 'True'">nightly</PreReleaseMilestone> <!-- Overwrite this property for nightly builds from the DEVELOP branch. -->
<!--
Date when Semantic Version was changed.
Expand All @@ -22,13 +22,16 @@
as it will restart file versions so 2.4.0-beta1 may have higher
file version (like 2.4.0.2222) than 2.4.0-beta2 (like 2.4.0.1111)
-->
<SemanticVersionDate>2020-09-08</SemanticVersionDate>
<SemanticVersionDate>2020-12-01</SemanticVersionDate>

<!--
Pre-release version is used to distinguish internally built NuGet packages.
Pre-release version = Minutes since semantic version was set, divided by 5 (to make it fit in a UInt16 (max 65535 = ~7 months).
BuildNumber uniquely identifies all builds (The max allowed value is UInt16.MaxValue = 65535).
The BuildNumber is used for nightly build package name and DLL assembly version.
NuGet uses alphanumeric sorting, so this value is padded with zeros.
BuildNumber = Hours since semantic version was set, divided by 12 (~89 years).
-->
<BuildNumber>$([MSBuild]::Divide($([System.DateTime]::Now.Subtract($([System.DateTime]::Parse($(SemanticVersionDate)))).TotalMinutes), 5).ToString('F0'))</BuildNumber>
<BuildNumberHours>$([MSBuild]::Divide($([System.DateTime]::Now.Subtract($([System.DateTime]::Parse($(SemanticVersionDate)))).TotalHours), 12))</BuildNumberHours>
<BuildNumber>$([System.Math]::Floor($(BuildNumberHours)).ToString('F0').PadLeft(5, '0'))</BuildNumber>

<VersionPrefix>$(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch)</VersionPrefix>
<VersionSuffix>$(PreReleaseMilestone)</VersionSuffix>
Expand Down
2 changes: 1 addition & 1 deletion .scripts/release_NupkgAudit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function Get-DoesDllVersionsMatch ([string]$dllPath) {

$message = "File Version: '$fileVersion' Assembly Version: '$assemblyVersion";
$requirement = "Versions should match."
Test-Condition ($fileVersion.Equals($assemblyVersion)) $message $requirement;
Test-Condition ([version]$fileVersion -eq [version]$assemblyVersion) $message $requirement;
}

function Get-IsValidPackageId([xml]$nuspecXml) {
Expand Down

0 comments on commit 8629b7a

Please sign in to comment.