@@ -27,17 +27,27 @@ $arm64ExtractPath = "win-dml-arm64-unzipped"
2727Write-Host " Extracting $arm64ZipFile to $arm64ExtractPath ..."
2828& $sevenZipPath x $arm64ZipFile - o" $arm64ExtractPath " - y
2929
30+ # Debug: List contents of extracted arm64 zip
31+ Write-Host " Contents of $arm64ExtractPath (recursive):"
32+ Get-ChildItem - Path $arm64ExtractPath - Recurse | ForEach-Object { Write-Host " - $ ( $_.FullName ) " }
33+
3034# 2. Find the target NuGet package.
3135# It finds all .nupkg files that do not contain "Managed" in their name.
32- $nupkgFiles = Get-ChildItem - Path . - Recurse - Filter * .nupkg | Where-Object { $_.Name -notlike " *Managed*" }
36+ $nupkgFiles = Get-ChildItem - Path . - Filter * .nupkg | Where-Object { ($_.Name -notlike " *Managed*" ) -and ($_.Name -notlike " *.symbols.nupkg" ) }
37+
38+ Write-Host " Found $ ( $nupkgFiles.Count ) candidate nupkg file(s) for bundling:"
39+ $nupkgFiles | ForEach-Object { Write-Host " - $ ( $_.FullName ) " }
3340
34- # 3. Validate that exactly one package was found.
35- if ($nupkgFiles.Count -ne 1 ) {
36- Write-Error " Error: Expected to find exactly one non-managed NuGet package, but found $ ( $nupkgFiles .Count ) ."
41+ # 3. Select the best package (shortest name prefers Release over Dev, and Main over Symbols)
42+ if ($nupkgFiles.Count -eq 0 ) {
43+ Write-Error " Error: No matching NuGet packages found to bundle into ."
3744 exit 1
3845}
39- $nupkg = $nupkgFiles [0 ]
40- Write-Host " Found package to process: $ ( $nupkg.Name ) "
46+ if ($nupkgFiles.Count -gt 1 ) {
47+ Write-Warning " Found multiple packages. Selecting the one with the shortest filename as the target for bundling."
48+ }
49+ $nupkg = $nupkgFiles | Sort-Object {$_.Name.Length } | Select-Object - First 1
50+ Write-Host " Selected target package: $ ( $nupkg.Name ) "
4151
4252# 4. Validate the package name matches the expected format.
4353if ($nupkg.Name -notlike " Microsoft.ML.OnnxRuntime.DirectML*.nupkg" ) {
@@ -61,14 +71,36 @@ New-Item -ItemType Directory -Path $tempDir | Out-Null
6171Write-Host " Extracting $ ( $nupkg.Name ) to $tempDir ..."
6272& $sevenZipPath x $nupkg.FullName - o" $tempDir " - y
6373
74+ # Debug: Print the .nuspec content
75+ $nuspecFile = Get-ChildItem - Path $tempDir - Filter * .nuspec | Select-Object - First 1
76+ if ($nuspecFile ) {
77+ Write-Host " Found manifest: $ ( $nuspecFile.FullName ) "
78+ Write-Host " --- Manifest Content ---"
79+ Get-Content $nuspecFile.FullName | ForEach-Object { Write-Host $_ }
80+ Write-Host " ------------------------"
81+ }
82+
83+ # Debug: List contents of extracted target nupkg
84+ Write-Host " Contents of $tempDir (recursive):"
85+ Get-ChildItem - Path $tempDir - Recurse | ForEach-Object { Write-Host " - $ ( $_.FullName ) " }
86+
6487# Step B: Create the new runtime directory structure.
6588$newRuntimePath = Join-Path $tempDir " runtimes\win-arm64\native"
89+ Write-Host " Ensuring destination path exists: $newRuntimePath "
6690New-Item - ItemType Directory - Path $newRuntimePath - Force | Out-Null
6791
6892# Step C: Copy the ARM64 binaries into the new structure.
6993$arm64SourcePath = Join-Path . " $arm64ExtractPath \runtimes\win-arm64\native"
70- Write-Host " Copying ARM64 binaries from $arm64SourcePath to $newRuntimePath ..."
71- Copy-Item - Path " $arm64SourcePath \*" - Destination $newRuntimePath - Recurse - Force
94+ if (Test-Path $arm64SourcePath ) {
95+ Write-Host " Copying ARM64 binaries from $arm64SourcePath to $newRuntimePath ..."
96+ $filesToCopy = Get-ChildItem - Path " $arm64SourcePath \*"
97+ Write-Host " Files found in source: $ ( $filesToCopy.Count ) "
98+ $filesToCopy | ForEach-Object { Write-Host " -> $ ( $_.Name ) " }
99+ Copy-Item - Path " $arm64SourcePath \*" - Destination $newRuntimePath - Recurse - Force
100+ } else {
101+ Write-Error " Error: ARM64 source path not found: $arm64SourcePath . Bailing out to avoid creating a broken package."
102+ exit 1
103+ }
72104
73105# Step D: Delete the original nupkg file.
74106Remove-Item - Path $nupkg.FullName - Force
@@ -79,6 +111,13 @@ Push-Location $tempDir
79111& $sevenZipPath a - tzip " $ ( $nupkg.FullName ) " " .\" - r
80112Pop-Location
81113
114+ # Debug: Check final nupkg existence
115+ if (Test-Path $nupkg.FullName ) {
116+ Write-Host " Final package created successfully: $ ( $nupkg.FullName ) "
117+ $finalSize = (Get-Item $nupkg.FullName ).Length
118+ Write-Host " Final package size: $finalSize bytes"
119+ }
120+
82121# --- Cleanup and Final Steps ---
83122Write-Host " Cleaning up temporary directory $tempDir ..."
84123Remove-Item - Recurse - Force $tempDir
@@ -91,4 +130,4 @@ Write-Host "Copying final artifact to $ArtifactStagingDirectory..."
91130Copy-Item - Path " .\Microsoft.ML.OnnxRuntime.DirectML*.nupkg" - Destination $ArtifactStagingDirectory - Force
92131
93132Write-Host " ---"
94- Write-Host " Script completed successfully."
133+ Write-Host " Script completed successfully."
0 commit comments