@@ -37,6 +37,11 @@ parameters:
3737 type : boolean
3838 default : false
3939
40+ - name : enable_android
41+ displayName : ' Whether Android AAR package is built.'
42+ type : boolean
43+ default : false
44+
4045- name : enable_apple_framework
4146 displayName : ' Whether Apple framework for iOS & MacCatalyst is built.'
4247 type : boolean
@@ -153,6 +158,20 @@ jobs:
153158 ArtifactName : onnxruntime-genai-osx-cpu-arm64-capi
154159 TargetPath : ' $(Build.BinariesDirectory)/artifact-downloads'
155160
161+ - ${{ if eq(parameters.enable_apple_framework, true) }} :
162+ - template : steps/utils/flex-download-pipeline-artifact.yml
163+ parameters :
164+ StepName : ' Download iOS XCFramework Artifacts'
165+ ArtifactName : onnxruntime-genai-ios-xcframework
166+ TargetPath : ' $(Build.BinariesDirectory)/artifact-downloads'
167+
168+ - ${{ if eq(parameters.enable_android, true) }} :
169+ - template : steps/utils/flex-download-pipeline-artifact.yml
170+ parameters :
171+ StepName : ' Download Android AAR Artifacts'
172+ ArtifactName : drop-android
173+ TargetPath : ' $(Build.BinariesDirectory)/artifact-downloads'
174+
156175 - checkout : self
157176 path : onnxruntime-genai
158177 clean : true
@@ -162,7 +181,7 @@ jobs:
162181
163182 - powershell : |
164183 dotnet --info
165- dotnet build Microsoft.ML.OnnxRuntimeGenAI.csproj -p:Configuration="$(buildConfig)" --verbosity normal
184+ dotnet build Microsoft.ML.OnnxRuntimeGenAI.csproj -p:Configuration="$(buildConfig)" -p:IncludeMobileTargets=true - -verbosity normal
166185 displayName: 'Build CSharp'
167186 workingDirectory: '$(Build.Repository.LocalPath)\src\csharp'
168187
@@ -181,10 +200,12 @@ jobs:
181200 - powershell : |
182201 $artifacts_dir = '$(Build.BinariesDirectory)/artifact-downloads'
183202 Write-Host "List downloaded artifacts"
184- $artifacts = Get-ChildItem -Path $artifacts_dir/* -Include *.zip,*.tar.gz
203+ $artifacts = Get-ChildItem -Path $artifacts_dir/* -Include *.zip,*.tar.gz,*.aar
185204 Write-Host $artifacts
186205
187206 $outputDir = '$(Build.Repository.LocalPath)/$(buildDir)'
207+ Write-Host "List extracted artifacts"
208+ Get-ChildItem -Path $nativeBuildOutputDir -Recurse
188209
189210 mkdir -Force $outputDir
190211 foreach ($file in $artifacts) {
@@ -195,28 +216,42 @@ jobs:
195216 $rid = $Matches.1
196217 }
197218 else {
198- Write-Host "Invalid artifact name" $file
199- return
219+ $rid_match = $a -match "onnxruntime-genai-(android|ios)-$(genai_version)(.+?)?(\.zip|\.aar)"
220+ if ($rid_match) {
221+ $rid = $Matches.1
222+ }
223+ else {
224+ Write-Host "Invalid artifact name" $file
225+ return
226+ }
200227 }
201- mkdir -Force $outputDir/$rid
202228
203- if ($a -like "*.zip") {
204- Expand-Archive -Path $file -DestinationPath $outputDir/$rid
229+ mkdir -Force $outputDir/$rid
230+ mkdir -Force $outputDir/$rid/$(buildConfig)
231+ if ($rid -like "ios") {
232+ Move-Item $file $outputDir/$rid/$(buildConfig)/onnxruntime-genai.xcframework.zip
233+ }
234+ elseif ($a -like "*.aar") {
235+ Move-Item $file $outputDir/$rid/$(buildConfig)/onnxruntime-genai.aar
205236 }
206- elseif ($a -like "*.tar.gz") {
207- tar -xf $file -C $outputDir/$rid
237+ else {
238+ if ($a -like "*.zip") {
239+ Expand-Archive -Path $file -DestinationPath $outputDir/$rid
240+ }
241+ elseif ($a -like "*.tar.gz") {
242+ tar -xf $file -C $outputDir/$rid
243+ }
208244 }
209245
210- mkdir -Force $outputDir/$rid/$(buildConfig)
211246 $b = $file.Basename
212247 $b = $b -split '.tar'
213248 $b = $b[0]
214- Move-Item $outputDir/$rid/$b/lib/* $outputDir/$rid/$(buildConfig) -Force
249+ if (Test-Path $outputDir/$rid/$b/lib/) {
250+ Move-Item $outputDir/$rid/$b/lib/* $outputDir/$rid/$(buildConfig) -Force
251+ }
252+ Get-ChildItem -Path $outputDir/$rid -Recurse
215253 }
216254
217- Write-Host "List extracted artifacts"
218- Get-ChildItem -Path $nativeBuildOutputDir -Recurse
219-
220255 displayName: 'Extract Artifacts & Prepare Native Libraries'
221256 workingDirectory: '$(Build.BinariesDirectory)/artifact-downloads'
222257
0 commit comments