Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Last active June 28, 2018 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guitarrapc/751d35d29ea2def878938dafe55b159b to your computer and use it in GitHub Desktop.
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
$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