Skip to content

Commit

Permalink
Merge pull request #5 from microsoft/skottmckay/AddSupportForXamarinT…
Browse files Browse the repository at this point in the history
…oCSharp

Merge Scott and Mike feature branches
  • Loading branch information
mikeparker104 authored Sep 10, 2021
2 parents bd966f8 + a1dabab commit d28b441
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
39 changes: 26 additions & 13 deletions tools/ci_build/github/windows/extract_nuget_files.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@

# Re-construct a build directory that contains binaries from all the different platforms we're including
# in the native ORT nuget package
New-Item -Path $Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo\nuget-artifacts -ItemType directory
$nuget_artifacts_dir = "$Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo\nuget-artifacts"
New-Item -Path $nuget_artifacts_dir -ItemType directory

## .zip files
# unzip directly
Get-ChildItem $Env:BUILD_BINARIESDIRECTORY\nuget-artifact -Filter *.zip |
Foreach-Object {
$cmd = "7z.exe x $($_.FullName) -y -o$Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo\nuget-artifacts"
$cmd = "7z.exe x $($_.FullName) -y -o$nuget_artifacts_dir"
Write-Output $cmd
Invoke-Expression -Command $cmd
}
Expand All @@ -28,34 +29,46 @@ Foreach-Object {
# 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$Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo\nuget-artifacts"
$cmd = "7z.exe x $($_.FullName) -y -o$nuget_artifacts_dir"
Write-Output $cmd
Invoke-Expression -Command $cmd
}

# copy android AAR folder (e.g. onnxruntime-android-full-aar)
Get-ChildItem $Env:BUILD_BINARIESDIRECTORY\nuget-artifact -Filter *-aar -Directory |
Foreach-Object {
Write-Output "Copy-Item -Recurse $($_.FullName) $Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo\nuget-artifacts"
Copy-Item -Recurse $_.FullName $Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo\nuget-artifacts
# copy android AAR.
$android_aar_dir = "$Env:BUILD_BINARIESDIRECTORY\nuget-artifact\onnxruntime-android-full-aar"
if (Test-Path -Path $android_aar_dir) {
# should only be one .aar file called onnxruntime-mobile-x.y.z.aar but sanity check that
$aars = Get-ChildItem $android_aar_dir -Filter onnxruntime-mobile-*.aar
if ($aars.Count -eq 1) {
$aar = $aars[0]
$target_dir = "$nuget_artifacts_dir\onnxruntime-android-aar"
$target_file = "$target_dir\onnxruntime.aar" # use name without '-mobile' and version in it when copying
New-Item -Path $target_dir -ItemType directory

Write-Output "Copy-Item $($aar.FullName) $target_file"
Copy-Item $aar.FullName $target_file
}
else{
Write-Error "Expected one Android .aar file but got: [$aars]"
}
}

New-Item -Path $Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\external\protobuf\cmake\RelWithDebInfo -ItemType directory

Copy-Item -Path $Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo\nuget-artifacts\onnxruntime-win-x64-*\lib\* -Destination $Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo
Copy-Item -Path $nuget_artifacts_dir\onnxruntime-win-x64-*\lib\* -Destination $Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo
Copy-Item -Path $Env:BUILD_BINARIESDIRECTORY\extra-artifact\protoc.exe $Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\external\protobuf\cmake\RelWithDebInfo

"Get-ChildItem -Directory -Path $Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo\nuget-artifacts\onnxruntime-*"
$ort_dirs = Get-ChildItem -Directory -Path $Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo\nuget-artifacts\onnxruntime-*
"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 $Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo\nuget-artifacts\$dirname
Rename-Item -Path $ort_dir -NewName $nuget_artifacts_dir\$dirname
}

# List artifacts
"Post copy artifacts"
Get-ChildItem -Recurse $Env:BUILD_BINARIESDIRECTORY\RelWithDebInfo\RelWithDebInfo\nuget-artifacts\
Get-ChildItem -Recurse $nuget_artifacts_dir\
2 changes: 1 addition & 1 deletion tools/nuget/generate_nuspec_for_native_nuget.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list):
if child_file.suffix == '.so' and is_this_file_needed(ep, child_file.name):
files_list.append('<file src="' + str(child_file) +
'" target="runtimes/linux-%s/native"/>' % cpu_arch)
if child.name == 'onnxruntime-android-full':
if child.name == 'onnxruntime-android':
for child_file in child.iterdir():
if child_file.suffix in ['.aar']:
files_list.append('<file src="' + str(child_file) +
Expand Down

0 comments on commit d28b441

Please sign in to comment.