Created
June 24, 2020 09:54
-
-
Save BurgerZ/05a1d648aa7851aeb72646fe4d145e31 to your computer and use it in GitHub Desktop.
Revisions
-
campbellja renamed this gist
Aug 31, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
campbellja revised this gist
Aug 31, 2016 . No changes.There are no files selected for viewing
-
campbellja created this gist
Aug 31, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,68 @@ $majorMinorVersion = "" $commitCount = & git rev-list --count HEAD Write-Output "git rev-list --count HEAD = $commitCount" $params = @{ FilePath = "" OS = "" ToolsDir = "" SolutionFolder = "" VersionSpecFilePath = "" BuildCounter = $commitCount SetBuildNumber = "%mr.Build.Version.SetTCBuildNumber%" } if(![System.IO.File]::Exists($params.FilePath)){ Write-Error "$params.FilePath does not exist" exit } $version = Retrieve-Version-From-Spec-File -Path $params.VersionSpecFilePath ` -BuildCount $params.BuildCounter ` Write-Host "##teamcity[buildNumber '$($version.PackageVersion)']" $fileXml = [xml] (Get-Content $params.FilePath ) $versionNumber = $version.PackageVersion $buildCounter = $params.BuildCounter if($params.OS -eq "iOS"){ Write-Output "Writing to $filePath - setting CFBundleVersion to $versionNumber" Select-Xml -xml $fileXml -XPath "//dict/key[. = 'CFBundleShortVersionString']/following-sibling::string[1]" | %{ $_.Node.InnerXml = $versionNumber } Select-Xml -xml $fileXml -XPath "//dict/key[. = 'CFBundleVersion']/following-sibling::string[1]" | %{ $_.Node.InnerXml = $buildCounter } } elseif($params.OS -eq "Android"){ $xpath = "//manifest" Write-Output "Writing to $filePath - setting manifest.android:versionCode to $versionNumber" Select-Xml -xml $fileXml -XPath $xpath | %{ $_.Node.SetAttribute("android:versionName", $versionNumber) $_.Node.SetAttribute("android:versionCode", $buildCounter) } } else{ Write-Error "Unrecognised OS argument: $params.OS" exit } $fileXml.Save($params.FilePath) Write-Output "Writing Version ($version.PackageVersion) to BuildVersion.txt" $version.PackageVersion | Out-File BuildVersion.txt