3

I started integrating Visual Studio App Center in my VSTS build pipeline.

Setup

After my iOS application is built, its binaries are sent to App Center. App Center does not build the app: VSTS does. Here is a screenshot of the latest builds and the version numbers:

VSTS - successful builds with appropriate version number

In Visual Studio App Center, I can't (re)use version number actually generated by the VSTS pipeline. As shown in the screen capture below, the version value is always 1.0 (1.0):

VS App Center - successful release with 1.0 version numbers

Question

In Visual Studio App Center, how can I associate the version number from the VSTS build to a release in VS App Center?

Kzryzstof
  • 7,688
  • 10
  • 61
  • 108

2 Answers2

5

Visual Studio App Center is supposed to grab the version information directly from the binaries.

In my case, the bash script used in VSTS to apply the proper version number in the AssemblyInfo.cs and the Info.plist got broken (it was not finding files anymore). All the generated binaries had the version version 1.0.

Fixing the script solved the problem.

enter image description here

Kzryzstof
  • 7,688
  • 10
  • 61
  • 108
2

Check the solution in case Auto incrementing build number for appxbundle package when deploying to appcenter via vsts:

You can update the version through PowerShell (add PowerShell task to build definition), the sample scripts: UpdateVersion.ps1

#Based on https://www.visualstudio.com/docs/build/scripts/index
# Enable -Verbose option
[CmdletBinding()] 

$VersionRegex = "\d+\.\d+\.\d+\.\d+"

$ManifestVersionRegex = " Version=""\d+\.\d+\.\d+\.\d+"""

if (-not $Env:BUILD_BUILDNUMBER)
{
    Write-Error ("BUILD_BUILDNUMBER environment variable is missing.")
    exit 1
}
Write-Verbose "BUILD_BUILDNUMBER: $Env:BUILD_BUILDNUMBER"

$ScriptPath = $null
try
{
    $ScriptPath = (Get-Variable MyInvocation).Value.MyCommand.Path
    $ScriptDir = Split-Path -Parent $ScriptPath
}
catch {}

if (!$ScriptPath)
{
    Write-Error "Current path not found!"
    exit 1
}

# Get and validate the version data
$VersionData = [regex]::matches($Env:BUILD_BUILDNUMBER,$VersionRegex)
switch($VersionData.Count)
{
   0        
      { 
         Write-Error "Could not find version number data in BUILD_BUILDNUMBER."
         exit 1
      }
   1 {}
   default 
      { 
         Write-Warning "Found more than instance of version data in BUILD_BUILDNUMBER." 
         Write-Warning "Will assume first instance is version."
      }
}
$NewVersion = $VersionData[0]
Write-Verbose "Version: $NewVersion"


$AssemblyVersion = $NewVersion
$ManifestVersion = " Version=""$NewVersion"""

Write-Host "Version: $AssemblyVersion"
Write-Host "Manifest: $ManifestVersion"
Write-Host "ScriptDir: " $ScriptDir

# Apply the version to the assembly property files
$assemblyInfoFiles = gci $ScriptDir -recurse -include "*Properties*","My Project" | 
    ?{ $_.PSIsContainer } | 
    foreach { gci -Path $_.FullName -Recurse -include AssemblyInfo.* }

if($assemblyInfoFiles)
{
    Write-Host "Will apply $AssemblyVersion to $($assemblyInfoFiles.count) Assembly Info Files."

    foreach ($file in $assemblyInfoFiles) {
        $filecontent = Get-Content($file)
        attrib $file -r
        $filecontent -replace $VersionRegex, $AssemblyVersion | Out-File $file utf8

        Write-Host "$file.FullName - version applied"
    }
}
else
{
    Write-Warning "No Assembly Info Files found."
}

# Try Manifests
$manifestFiles = gci .\ -recurse -include "Package.appxmanifest" 

if($manifestFiles)
{
    Write-Host "Will apply $ManifestVersion to $($manifestFiles.count) Manifests."

    foreach ($file in $manifestFiles) {
        $filecontent = Get-Content($file)
        attrib $file -r
        $filecontent -replace $ManifestVersionRegex, $ManifestVersion | Out-File $file utf8

        Write-Host "$file.FullName - version applied to Manifest"
    }
}
else
{
    Write-Warning "No Manifest files found."
}

Write-Host ("##vso[task.setvariable variable=AppxVersion;]$NewVersion")

More information, you can refer to this article: Set up a continuous deployment build for sideloading

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
  • I am not sure I understand how this will help. It looks like it is related to the versioning of an AppX package (I am guessing a UWP app). In my case, I do version my iOS application using a bash script. I do not know how it can be picked up by App Center? Where the 1.0 (1.0) in App Center comes from? Is it because I made a mistake and my app is actually not versioned? – Kzryzstof Jul 16 '18 at 10:08
  • I'll be damned. Turns out my script is broken and does not update the version number in the assembly. I will fix it and see if everything is working. – Kzryzstof Jul 16 '18 at 12:26