onnxruntime/tools/ci_build/github/windows/extract_nuget_files.ps1
Changming Sun 5f6a3158f8
Enable VCPKG in CI build (#23426)
### Description
1. Enable VCPKG flag in Windows CPU CI build pipelines. 
2. Increased the min supported cmake version from 3.26 to 3.28. Because
of it, drop the support for the old way of finding python by
"find_package(PythonLibs)". Therefore, in build.py we no longer set
"PYTHON_EXECUTABLE" cmake var when doing cmake configure.
3. Added "xnnpack-ep" as a feature for ORT's vcpkg config.
4. Added asset cache support for ORT's vcpkg build
5. Added VCPKG triplet files for Android build.
6. Set VCPKG triplet to "universal2-osx" if CMAKE_OSX_ARCHITECTURES was
found in cmake extra defines.
7. Removed a small piece of code in build.py, which was for support CUDA
version < 11.8.
8. Fixed an issue that CMAKE_OSX_ARCHITECTURES sometimes got specified
twice when build.py invoked cmake.
9. Added more model tests to Android build. After this change, we will
test all ONNX versions instead of just the latest one.
10. Fixed issues that are related to build.py's "--build_nuget"
parameter. Also, enable the flag in most Windows CPU CI build jobs.
11. Removed a restriction in build.py that disallowed cross-compiling
Windows ARM64 nuget package on Windows x86.
 
### Motivation and Context
Adopt vcpkg.
2025-02-05 10:58:53 -08:00

105 lines
4.2 KiB
PowerShell

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# This file is used by Zip-Nuget Packaging NoContribOps Pipeline,Zip-Nuget-Java Packaging Pipeline
# Re-construct a build directory that contains binaries from all the different platforms we're including
# in the native ORT nuget package
$nuget_artifacts_dir = "$Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo\nuget-artifacts"
New-Item -Path $nuget_artifacts_dir -ItemType directory
## .zip files
# unzip directly
# exclude the iOS xcframework as we need to leave that zipped up to preserve symlinks
Get-ChildItem -Path $Env:BUILD_BINARIESDIRECTORY\nuget-artifact\* -Include *.zip -Exclude onnxruntime_ios_xcframework.*.zip |
Foreach-Object {
$cmd = "7z.exe x $($_.FullName) -y -o$nuget_artifacts_dir"
Write-Output $cmd
Invoke-Expression -Command $cmd
}
## .tgz files
# first extract the tar file from the tgz
Get-ChildItem $Env:BUILD_BINARIESDIRECTORY\nuget-artifact -Filter *.tgz |
Foreach-Object {
$cmd = "7z.exe x $($_.FullName) -y -o$Env:BUILD_BINARIESDIRECTORY\nuget-artifact"
Write-Output $cmd
Invoke-Expression -Command $cmd
}
# now extract the actual folder structure from the tar file to the build dir
Get-ChildItem $Env:BUILD_BINARIESDIRECTORY\nuget-artifact -Filter *.tar |
Foreach-Object {
$cmd = "7z.exe x $($_.FullName) -y -o$nuget_artifacts_dir"
Write-Output $cmd
Invoke-Expression -Command $cmd
}
# process iOS xcframework
$xcframeworks = Get-ChildItem $Env:BUILD_BINARIESDIRECTORY\nuget-artifact -Filter onnxruntime_ios_xcframework.*.zip
if ($xcframeworks.Count -eq 1) {
$xcframework = $xcframeworks[0]
$target_dir = "$nuget_artifacts_dir\onnxruntime-ios-xcframework"
# remove version info from filename and use required filename format
$target_file = "$target_dir\onnxruntime.xcframework.zip"
New-Item -Path $target_dir -ItemType directory
Write-Output "Copy-Item $($xcframework.FullName) $target_file"
Copy-Item $xcframework.FullName $target_file
}
elseif ($xcframeworks.Count -gt 1) {
Write-Error "Expected at most one onnxruntime_ios_xcframework*.zip file but got: [$xcframeworks]"
}
# copy android AAR.
# for full build of onnxruntime Android AAR, there should only be one .aar file
# called onnxruntime-android-x.y.z.aar or onnxruntime-training-android-x.y.z.aar but sanity check that
$aars = Get-ChildItem $Env:BUILD_BINARIESDIRECTORY\nuget-artifact -Filter *.aar
if ($aars.Count -eq 1) {
$aar = $aars[0]
$aar_prefix = "onnxruntime"
if ($aar -like "onnxruntime-training*") {
$aar_prefix = "onnxruntime-training"
}
$target_dir = "$nuget_artifacts_dir\$aar_prefix-android-aar"
$target_file = "$target_dir\onnxruntime.aar" # remove '-mobile' and version info from filename
New-Item -Path $target_dir -ItemType directory
Write-Output "Copy-Item $($aar.FullName) $target_file"
Copy-Item $aar.FullName $target_file
}
elseif ($aars.Count -gt 1) {
Write-Error "Expected at most one Android .aar file but got: [$aars]"
}
# Check whether this is a training pipeline
$is_training_pipeline = $false
if (Test-Path -Path $nuget_artifacts_dir\onnxruntime-training-win-x64-*) {
$is_training_pipeline = $true
Write-Output "onnxruntime-training-win-x64-* dir exists. This is a training pipeline."
}
# Copy onnxruntime and protoc binaries to the binaries dir as these are required
# by Microsoft.ML.OnnxRuntime.Tests.NetCoreApp
if ($is_training_pipeline) {
Copy-Item -Path $nuget_artifacts_dir\onnxruntime-training-win-x64-*\lib\* -Destination $Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo
}
else {
Copy-Item -Path $nuget_artifacts_dir\onnxruntime-win-x64-*\lib\* -Destination $Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo
}
"Get-ChildItem -Directory -Path $nuget_artifacts_dir\onnxruntime-*"
$ort_dirs = Get-ChildItem -Directory -Path $nuget_artifacts_dir\onnxruntime-*
foreach ($ort_dir in $ort_dirs)
{
# remove the last '-xxx' segment from the dir name. typically that's the architecture.
$dirname = Split-Path -Path $ort_dir -Leaf
$dirname = $dirname.SubString(0,$dirname.LastIndexOf('-'))
Write-Output "Renaming $ort_dir to $dirname"
Rename-Item -Path $ort_dir -NewName $nuget_artifacts_dir\$dirname
}
# List artifacts
"Post copy artifacts"
Get-ChildItem -Recurse $nuget_artifacts_dir\