4

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?

Guillaume Perrot
  • 3,978
  • 2
  • 25
  • 33
Sebastian Zolg
  • 1,721
  • 1
  • 11
  • 29
  • Since you are working with Microsoft, why don't you ask them about an infrastructure they support? – IInspectable Dec 09 '17 at 19:04
  • @IInspectable - sure, I gonna ask them but this will also take time to clarify. I keep this post updated. Already posted my workaround as I need a quick solution. – Sebastian Zolg Dec 10 '17 at 11:29

2 Answers2

2

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.

Sebastian Zolg
  • 1,721
  • 1
  • 11
  • 29
  • how did you replace this? i've massie trouble to deploy our app via appcenter too. the reason is, that in the appxbundle the .netcore runtime is not included. so the installer ask the client to retrieve that package from the developer. I search for a few days now, and i did not manage it to deploy via appcenter – The Chris Feb 13 '18 at 10:17
  • @ChrisTTian667 I once hat a similar issue. Have you upgraded your project multiple times over month, like from old project.json to csproj style? Check your build configuration & target platform. Also see that you have not targeted "any cpu" instead try to build for x64 only and see if the result is the same. – Sebastian Zolg Feb 14 '18 at 16:50
  • In order to use your script (I'm not expericenced in ps), don't we have to "download" the App Center Cli first somewhere/somehow? – François Oct 30 '18 at 07:29
  • @François Yes you're right. I've updated my response at the end to give a little guidance on this. Let me know if you need anything else. – Sebastian Zolg Oct 30 '18 at 08:16
  • Meanwhile, I had found that one, tks! Now I'm facing an issue where `$binayFile` is empty. The file is in `$(Build.ArtifactStagingDirectory)\AppxPackages\*.appxbundle` and the ps script doesn't find it just the way you do it (yes I did replaced `MyApp` with my app name ;-)) – François Oct 30 '18 at 12:37
  • @François Make sure your powershell build step has working directory set to $(Build.ArtifactStagingDirectory)\AppxPackages so you can reuse my code 1:1. The recurse switch in the script is important as the appxbundle file is not necessarily directly located under \AppxPackages\ folder. – Sebastian Zolg Oct 30 '18 at 13:50
  • Now that I set my working directory, ps complains that `./AppCenterDistributeThroughCli.ps1` (that's where I've put your script) is not found lol – François Oct 30 '18 at 16:03
  • I've added an answer with my ps task consuming your script. Tks again. – François Oct 30 '18 at 16:53
0

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.

François
  • 2,765
  • 21
  • 45