onnxruntime/tools/ci_build/github/azure-pipelines/nuget/templates/test_android.yml

133 lines
5.1 KiB
YAML

parameters:
AgentPool : 'Win-CPU'
ArtifactSuffix: ''
SpecificArtifact: false
BuildId: ''
stages:
- stage: NuGet_Test_Android
jobs:
- job: NuGet_Test_Android
workspace:
clean: all
pool: "${{ parameters.AgentPool }}"
variables:
- name: OnnxRuntimeBuildDirectory
value: '$(Build.BinariesDirectory)'
steps:
- task: NuGetToolInstaller@0
displayName: Use Nuget 6.10.x
inputs:
versionSpec: 6.10.x
- task: PowerShell@2
displayName: Download NuGet package
inputs:
targetType: 'inline'
script: |
New-Item -Path $(Build.SourcesDirectory)\nuget-artifact -ItemType Directory
nuget install Microsoft.ML.OnnxRuntime -OutputDirectory nuget-artifact -Source https://api.nuget.org/v3/index.json
workingDirectory: '$(Build.SourcesDirectory)'
- template: get-nuget-package-version-as-variable.yml
parameters:
packageFolder: '$(Build.SourcesDirectory)\nuget-artifact'
- task: PowerShell@2
displayName: Install MAUI workloads
inputs:
targetType: 'inline'
script: |
dotnet workload install maui maui-android android
workingDirectory: '$(Build.SourcesDirectory)\csharp'
- task: PowerShell@2
displayName: List installed workloads
inputs:
targetType: 'inline'
script: |
$output = dotnet --list-sdks
Write-Output $output
$output1 = dotnet workload list
Write-Output $output1
workingDirectory: '$(Build.SourcesDirectory)\csharp'
- task: PowerShell@2
displayName: Generating MAUI keystore
inputs:
targetType: 'inline'
script: |
Write-Host "Generating debug.keystore"
keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Android Debug,O=Android,C=US"
workingDirectory: '$(Build.SourcesDirectory)\csharp'
- task: PowerShell@2
displayName: Publish Android MAUI APK
inputs:
targetType: 'inline'
script: |
dotnet nuget add source $(Build.SourcesDirectory)\nuget-artifact --name local-nuget
dotnet publish -c Release --property:UsePrebuiltNativePackage=true --property:CurrentOnnxRuntimeVersion=$(NuGetPackageVersionNumber) -f net8.0-android -p:AndroidKeyStore=true -p:AndroidSigningKeyAlias=androiddebugkey -p:AndroidSigningKeyPass=android -p:AndroidSigningKeyStore=debug.keystore -p:AndroidSigningStorePass=android
workingDirectory: '$(Build.SourcesDirectory)\csharp\test\Microsoft.ML.OnnxRuntime.Tests.MAUI'
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$folderPath = "$(Build.SourcesDirectory)"
$fileExtension = "*.apk"
Write-Host "Searching for files with extension $fileExtension in $folderPath"
$files = Get-ChildItem -Path $folderPath -Recurse -Filter $fileExtension
if ($files) {
Write-Host "Found files:"
$files | ForEach-Object { Write-Host $_.FullName }
} else {
Write-Host "No files found."
}
displayName: 'Search for APK files recursively'
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$folderPath = "$(Build.SourcesDirectory)"
$fileExtension = "*.aab"
Write-Host "Searching for files with extension $fileExtension in $folderPath"
$files = Get-ChildItem -Path $folderPath -Recurse -Filter $fileExtension
if ($files) {
Write-Host "Found files:"
$files | ForEach-Object { Write-Host $_.FullName }
} else {
Write-Host "No files found."
}
displayName: 'Search for AAB files recursively'
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$folderPath = "$(Build.SourcesDirectory)\csharp\test\Microsoft.ML.OnnxRuntime.Tests.MAUI\bin\Release\net8.0-android\publish"
Write-Host "Listing all files in $folderPath"
$files = Get-ChildItem -Path $folderPath -Recurse | Where-Object { -not $_.PSIsContainer }
if ($files) {
Write-Host "Found files:"
$files | ForEach-Object { Write-Host $_.FullName }
} else {
Write-Host "No files found."
}
displayName: 'List all files in directory'
- task: CopyFiles@2
displayName: 'Copy apk to staging directory'
inputs:
SourceFolder: '$(Build.SourcesDirectory)\csharp\test\Microsoft.ML.OnnxRuntime.Tests.MAUI\bin\Release\net8.0-android\publish'
Contents: '*-Signed.apk'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishPipelineArtifact@0
displayName: 'Publish apk packages files'
inputs:
artifactName: 'test signed apk'
targetPath: '$(Build.ArtifactStagingDirectory)'