Xamarin Forms Devops, Build, Sign and Distribute for Test... APK not signing properly... no errors.

Stewart Basterash 81 Reputation points
2021-07-19T02:41:23.543+00:00

I am working on transitioning to Azure DevOps for source control and automated build process for Xamarin Forms. Here is the initial test process for a Xamarin Forms App...

Start with default Xamarin Forms Android App... tabbed default. Creates App1 successfully.

Build and Test Run Xamarin Forms "App1"... Success.

Archive "App1", AdHoc Distribution... apply Keystore Key... and Save to Shared Directory.

Install "Third Party" app to test device... Success. Install runs as expected.

Devops Integration:

Create DevOps Project.

Inside Visual Studio Use Source Control GIT (local) and DevOps Repo (url provided in DevOps Repos)

Code verified and uploaded to DevOps successfully.

Create Build Pipeline for Xamarin... Build is Successful.

Add Keystore Key (same used for AdHoc Build) to DevOps secure files from Local C:\Users\UserID\appdata\local\xamarin\mono..."

Add Variables for Keystrore, key-alias, and key-password.

Add Signing Task... Test Build Successful (no errors).

Add "PublishBuildArtifact" task, to link APK and allow for download on test device.

Download will not install on device! It appears that the keystore key is not properly applied to apk file... but there are no errors.

Any help would be appreciated...

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,298 questions
Azure DevTest Labs
Azure DevTest Labs
An Azure service that is used for provisioning development and test environments.
256 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Stewart Basterash 81 Reputation points
    2021-07-19T02:58:10.263+00:00

    I was told I wrote this question on the wrong forum... since posting, I have answered my own question... The Xamarin Forms Build Pipeline yml file contains entries for a variable created 'outputDirectory'... If you use this to begin your process this certainly works for build... When you get to signing, you need the folder where the compiled output APK is... If you use 'ouputDirectory' This doesn't seem to work... My WORKING YML for Build, Sign and Show Artifact is below...

    Using 'outputDirectory' as it appears in the yml file will not allow a signed apk (for unknown reasons), once I changed all the references in the script to use 'Build.ArtifactStagingDirectory'... everything began working... 2 hours of my life I'll never get back again.

    NEW DEFAULT YML CONFIGURATION FOR XAMARIN FORMS

    Xamarin.Android

    Build a Xamarin.Android project.

    Add steps that test, sign, and distribute an app, save build artifacts, and more:

    https://learn.microsoft.com/azure/devops/pipelines/languages/xamarin

    trigger:

    • master

    pool:
    vmImage: 'macos-latest'

    variables:
    buildConfiguration: 'Release'
    outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'

    steps:

    • task: NuGetToolInstaller@1
    • task: NuGetCommand@2
      inputs:
      restoreSolution: '**/*.sln'
    • task: XamarinAndroid@1
      inputs:
      projectFile: '**/droid.csproj'
      outputDirectory: '$(outputDirectory)'
      configuration: '$(buildConfiguration)'

    THIS IS WHAT IS CURRENTLY WORKING...

    Xamarin.Android

    trigger:

    • master

    pool:
    vmImage: 'macos-latest'

    variables:
    buildConfiguration: 'Release'
    outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'

    steps:

    • task: NuGetToolInstaller@1
    • task: NuGetCommand@2
      inputs:
      restoreSolution: '**/*.sln'
    • task: XamarinAndroid@1
      inputs:
      projectFile: '**/droid.csproj'
      outputDirectory: '$(Build.ArtifactStagingDirectory)'
      configuration: '$(buildConfiguration)'
    • task: AndroidSigning@3
      inputs:
      apkFiles: '$(Build.ArtifactStagingDirectory)/*.apk'
      apksignerKeystoreFile: 'ATLED.keystore'
      apksignerKeystorePassword: '$(keystore-password)'
      apksignerKeystoreAlias: '$(key-alias)'
      apksignerKeyPassword: '$(key-password)'

      Build a Xamarin.Android project.

    Add steps that test, sign, and distribute an app, save build artifacts, and more:

    https://learn.microsoft.com/azure/devops/pipelines/languages/xamarin

    • task: PublishBuildArtifacts@1
      inputs:
      pathtoPublish: '$(Build.ArtifactStagingDirectory)'
    1 person found this answer helpful.