Last active
June 28, 2018 10:48
-
-
Save guitarrapc/751d35d29ea2def878938dafe55b159b to your computer and use it in GitHub Desktop.
This version replace BuildVersion(0.0.x.0) of AppManifest with VSTS BuildID. original : https://gist.github.com/ridomin/7250c9fb3fbc74593c7f97520a3fe771
This file contains 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 characters
$env:UWPOutputPath = "./UWP" | |
$env:BUILD_BUILDID = 0 | |
$env:EnableSideload = "true" | |
$enableSideload = [bool]::Parse($env:EnableSideload) | |
$manifestVersionRegex = " Version=""\d+\.\d+\.\d+\.\d+""" | |
$versionRegex = "\d+\.\d+\.\d+\.\d+" | |
$manifestFiles = Get-ChildItem -LiteralPath $env:UWPOutputPath -Recurse -Filter "Package.appxmanifest" | |
foreach ($file in $manifestFiles){ | |
$content = Get-Content $file.FullName -Encoding utf8 | |
if (($content | where {$_ -match $manifestVersionRegex}) -and ($Matches[0] -match $versionRegex)) { | |
$currentVersion = [version]$Matches[0] | |
$newVersion = if ($enableSideload){ "{0}.{1}.{2}.{3}" -f $currentVersion.Major, $currentVersion.Minor, $env:BUILD_BUILDID, 0 }else{ $currentVersion.ToString() } | |
$manifestVersion = " Version=""$newVersion""" | |
} | |
if ($enableSideload){ $content -replace $manifestVersionRegex, $manifestVersion | Out-File $file.FullName -Encoding utf8 } | |
Write-Host ("##vso[task.setvariable variable=AppxVersion;]$newVersion") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment