Merge pull request #6788 from microsoft/dev/crutkas/buildFarmVersioningTake3

Getting version numbers set by the build farm
This commit is contained in:
Clint Rutkas 2020-10-29 20:24:27 -07:00 committed by GitHub
commit 5417afc623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 4 deletions

View File

@ -25,7 +25,7 @@
<Upgrade Id="42B84BF7-5FBF-473B-9C8B-049DC16F7708">
<UpgradeVersion
Minimum="0.11.0" Maximum="$(var.Version)"
Minimum="0.0.0" Maximum="$(var.Version)"
Property="PREVIOUSVERSIONSINSTALLED"
IncludeMinimum="yes" IncludeMaximum="no" />
</Upgrade>
@ -982,4 +982,4 @@
</ComponentGroup>
</Fragment>
</Wix>
</Wix>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Version>0.23.1</Version>
<Version>0.0.1</Version>
<DevEnvironment>Local</DevEnvironment>
</PropertyGroup>
</Project>
</Project>

View File

@ -0,0 +1,41 @@
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
[string]$versionNumber = "0.0.1",
[Parameter(Mandatory=$True,Position=2)]
[AllowEmptyString()]
[string]$DevEnvironment = "Local"
)
Write-Host $PSScriptRoot
$versionRegex = "(\d+)\.(\d+)\.(\d+)"
if($versionNumber -match $versionRegEx)
{
$buildDayOfYear = (Get-Date).DayofYear;
$buildTime = Get-Date -Format HH;
# $buildTime = Get-Date -Format HHmmss;
# $buildYear = Get-Date -Format yy;
# $revision = [string]::Format("{0}{1}{2}", $buildYear, $buildDayOfYear, $buildTime )
# max UInt16, 65535
#$revision = [string]::Format("{0}{1}", $buildDayOfYear, $buildTime )
#Write-Host "Revision" $revision
$versionNumber = [int]::Parse($matches[1]).ToString() + "." + [int]::Parse($matches[2]).ToString() + "." + [int]::Parse($matches[3]).ToString() # + "." + $revision
Write-Host "Version Number" $versionNumber
}
else{
throw "Build format does not match the expected pattern (buildName_w.x.y.z)"
}
$verPropWriteFileLocation = $PSScriptRoot + '/../../src/Version.props';
$verPropReadFileLocation = $verPropWriteFileLocation;
[XML]$verProps = Get-Content $verPropReadFileLocation
$verProps.Project.PropertyGroup.Version = $versionNumber;
$verProps.Project.PropertyGroup.DevEnvironment = $DevEnvironment;
Write-Host "xml" $verProps.Project.PropertyGroup.Version
$verProps.Save($verPropWriteFileLocation);