question

StewartBasterash-9314 avatar image
0 Votes"
StewartBasterash-9314 asked kobulloc-MSFT commented

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

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...

dotnet-xamarinazure-devtestlabs
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

StewartBasterash-9314 avatar image
1 Vote"
StewartBasterash-9314 answered kobulloc-MSFT commented

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://docs.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://docs.microsoft.com/azure/devops/pipelines/languages/xamarin

  • task: PublishBuildArtifacts@1
    inputs:
    pathtoPublish: '$(Build.ArtifactStagingDirectory)'

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@StewartBasterash-9314 You are correct, we like to direct people to the active DevOps community for DevOps related issues but I also really appreciate you updating this issue with your answer (you can accept your own answer and it makes it easier for others who read this). Thank you! I know that this will be helpful to anyone else who runs into this and I'm going to leave it as is.

For anyone who may have DevOps related questions, the Azure DevOps team and DevOps community are actively answering questions here:

https://developercommunity.visualstudio.com/spaces/21/index.html

0 Votes 0 ·