Distribute UWP App to App Center (aka Mobile Center) using VSTS Task

1.2k views Asked by At

I'm currently working together with Microsoft on a case where one of your UWP Apps is crashing after start. After a lot of debugging around msbuild I recognized that the crash only occurs when the resulting appxbundle file is distributed over Microsoft App Center (aka Mobile Center). This is also only the case when the appxbundle is uploaded to App Center with the VSTS built in task "App Center distribute".

When I upload the appxbundle manually using the App Center Portal it all works fine, even when consumed through App Center.

Furthermore I noticed that the appxbundle is 18MB in size after build, but is only 14MB in size when uploaded to App Center using the VSTS task (size is shown in App Center Portal). The file is not corrupt after a download but it seems to miss some files in the bundle - what is this task doing? Opening and modifying the appxbundle? uhhhhhh.

Anybody having a similar issue?

2

There are 2 answers

8
Sebastian Zolg On BEST ANSWER

I've worked around this issue for the moment by replacing the built-in task with the App Center CLI and a simple powershell script to archive the same.

param(
    [Parameter(Mandatory=$true)]
    [String]
    $Token,
    # Name of the App, e.g. 'org/app'
    [Parameter(Mandatory=$true)]
    [String]
    $App,
    # Name of the distribution Group, e.g. 'Collaborators'
    [Parameter(Mandatory=$true)]
    [String]
    $Group
)

$binaryFile = (Get-ChildItem MyApp_*_x64.appxbundle -Recurse).FullName
appcenter distribute release -g $Group -f "$binaryFile" -a $App --debug --token $Token

To make this script work, you need the latest version of App Center CLI which can be found here.

On a build agent with NPM package manager present, you can simply run npm install -g appcenter-cli to install the latest version. Afterwards the above script should execute.

0
François On

I used @SebastianZolg's solution this way:

- task: PowerShell@2
displayName: 'Distribute via AppCenter'
inputs:
    targetType: 'filePath'
    filePath: 'AppCenterDistributeThroughCli.ps1'
    arguments: xxxMyTokenxxxxx MyAppCenterAppSlug "Collaborators"
    workingDirectory: '$(Build.ArtifactStagingDirectory)\AppxPackages'

And AppCenterDistributeThroughCli.ps1 is @SebastianZolg's script.