<# .SYNOPSIS Assemble a complete link-time ONNX Runtime C/C++ SDK (include\ + lib\) by downloading the public headers at a given source commit and pairing them with an existing import lib. Output feeds straight into tools\bump_ort_sdk.ps1. .DESCRIPTION ORT nightly builds (e.g. 1.24.YYYYMMDD.N.) ship DLLs + import libs but the matching C/C++ headers are only the public source files in the GitHub repo at the build's commit. ANSCORE compiles against ORT_API_VERSION via these headers, so this script pulls the exact header set for -Commit and copies in a matching onnxruntime.lib, producing a ready-to-install SDK folder. Default -Commit 058787c matches SharedCore\ep\cuda (1.24.20260218) AND the onnxruntime.lib already on disk under LabellingTool\vendor (same build). .PARAMETER Commit ORT source commit/branch/tag to fetch headers from. Default: 058787c (API 24). .PARAMETER OutDir Where to assemble the SDK. Default: %TEMP%\ort_sdk_. .PARAMETER LibSource Folder containing onnxruntime.lib (+ onnxruntime_providers_shared.lib) of the SAME build. Default: the LabellingTool vendor folder found on this machine. .EXAMPLE .\fetch_ort_headers.ps1 .\bump_ort_sdk.ps1 -SdkPath $env:TEMP\ort_sdk_058787c -Marker runtime1.24.0_openvino2025.3.0.txt -WhatIf #> [CmdletBinding()] param( [string] $Commit = "058787c", [string] $OutDir, [string] $LibSource = "C:\Projects\CLionProjects\LabellingTool\vendor\onnxruntime-win\lib" ) $ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 if (-not $OutDir) { $OutDir = Join-Path $env:TEMP "ort_sdk_$Commit" } $incDir = Join-Path $OutDir 'include' $libDir = Join-Path $OutDir 'lib' New-Item -ItemType Directory -Force -Path $incDir, $libDir | Out-Null $base = "https://raw.githubusercontent.com/microsoft/onnxruntime/$Commit/include/onnxruntime/core" # Header set ANSCORE links against (mirrors ANSLibs, minus unused training headers). # Each entry: subpath under .../core/ -> flattened into include\ $headers = @( "session/onnxruntime_c_api.h", "session/onnxruntime_cxx_api.h", "session/onnxruntime_cxx_inline.h", "session/onnxruntime_float16.h", "session/onnxruntime_lite_custom_op.h", "session/onnxruntime_run_options_config_keys.h", "session/onnxruntime_session_options_config_keys.h", "session/onnxruntime_ep_c_api.h", "session/onnxruntime_ep_device_ep_metadata_keys.h", "providers/cpu/cpu_provider_factory.h", "framework/provider_options.h" ) Write-Host "== Fetching ORT headers @ $Commit -> $incDir ==" $ok = 0; $fail = @() foreach ($h in $headers) { $name = Split-Path $h -Leaf $url = "$base/$h" try { Invoke-WebRequest -Uri $url -OutFile (Join-Path $incDir $name) -UseBasicParsing # Guard against a 200-with-HTML (GitHub 404 page) sneaking through $first = Get-Content -LiteralPath (Join-Path $incDir $name) -TotalCount 1 -ErrorAction SilentlyContinue if ($first -match '^\s*