Update Microsoft.ML.OnnxRuntime.Foundry Package#27294
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Microsoft.ML.OnnxRuntime.Foundry packaging pipeline and related build/restore behaviors to better support Windows ARM64 and Foundry’s dependency/signing requirements.
Changes:
- Switch Windows ARM64 packaging from
--arm64ecto--arm64. - Add a dedicated Foundry local NuGet packaging stage template with ESRP signing.
- Fix MSBuild props to only copy ARM/ARM64 native DLLs when they exist, avoiding restore/build failures on ARM64 machines for non-ARM64 packages.
- Add a NuGet dependency so Foundry pulls in
Microsoft.ML.OnnxRuntime.Gpu.Linux.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| tools/nuget/generate_nuspec_for_native_nuget.py | Adds Microsoft.ML.OnnxRuntime.Gpu.Linux dependency when generating dependencies for the Foundry package. |
| tools/ci_build/github/azure-pipelines/templates/foundry-local-nuget-packaging.yml | New Azure Pipelines template for creating/signing the Foundry local NuGet package from downloaded artifacts. |
| tools/ci_build/github/azure-pipelines/custom-nuget-packaging-pipeline.yml | Updates ARM64 build flag and switches Foundry packaging logic to the new template. |
| csharp/src/Microsoft.ML.OnnxRuntime/targets/netstandard/props.xml | Adds Exists(...) checks before copying ARM/ARM64 onnxruntime.dll to output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tools/ci_build/github/azure-pipelines/templates/foundry-local-nuget-packaging.yml
Outdated
Show resolved
Hide resolved
tools/ci_build/github/azure-pipelines/templates/foundry-local-nuget-packaging.yml
Outdated
Show resolved
Hide resolved
tools/ci_build/github/azure-pipelines/templates/foundry-local-nuget-packaging.yml
Outdated
Show resolved
Hide resolved
tools/ci_build/github/azure-pipelines/templates/foundry-local-nuget-packaging.yml
Outdated
Show resolved
Hide resolved
tools/ci_build/github/azure-pipelines/custom-nuget-packaging-pipeline.yml
Outdated
Show resolved
Hide resolved
tools/ci_build/github/azure-pipelines/custom-nuget-packaging-pipeline.yml
Outdated
Show resolved
Hide resolved
tianleiwu
left a comment
There was a problem hiding this comment.
Review Summary for PR 27294: Update Microsoft.ML.OnnxRuntime.Foundry Package
Overview
This PR focuses on improving the Microsoft.ML.OnnxRuntime.Foundry package by:
- Windows ARM64 Support: Switching from
arm64ecto purearm64. - Refactoring: Moving packaging logic to a new template
foundry-local-nuget-packaging.yml. - Bug Fix: Preventing build failures on ARM64 machines when non-native packages invoke
props.xmlchecks. - Dependencies: Adding
Microsoft.ML.OnnxRuntime.Gpu.Linuxas a dependency. - Platform Support: Explicit removal of
osx-x64support from this custom package.
Detailed Changes
1. Build Logic Refactoring
File: tools/ci_build/github/azure-pipelines/custom-nuget-packaging-pipeline.yml -> tools/ci_build/github/azure-pipelines/templates/foundry-local-nuget-packaging.yml
- Change: The explicit packaging steps were removed from the main pipeline file and modularized into a new reuseable template
foundry-local-nuget-packaging.yml. - Impact: Improves pipeline readability and reusability. The logic for downloading artifacts, processing them (including the new
osx-arm64directory handling), and signing (ESRP) is now encapsulated.
2. Platform Support Changes (OSX & Windows ARM64)
Files: tools/nuget/generate_nuspec_for_custom_nuget.py, tools/ci_build/github/azure-pipelines/templates/foundry-local-nuget-packaging.yml
- OSX-X64 Removal: The support for
osx-x64has been removed fromgenerate_nuspec_for_custom_nuget.pyand is not present in the new pipeline template.- Note: Ensure this removal is intentional for the Foundry package.
- Windows ARM64: The PR description mentions "Builds arm64 as opposed to previous arm64ec". The pipeline now explicitly handles
win-arm64artifacts.
3. MSBuild Props Fix
File: csharp/src/Microsoft.ML.OnnxRuntime/targets/netstandard/props.xml
- Change: Added
Condition="Exists(...)"checks before copying the nativeonnxruntime.dll.<None Condition="Exists('$(MSBuildThisFileDirectory)..\..\runtimes\win-arm64\native\onnxruntime.dll')" Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-arm64\native\onnxruntime.dll">
- Impact: This is a robust fix. Previously, if a project referenced a package that didn't contain the ARM64 binary (e.g.,
Microsoft.ML.OnnxRuntime.Gpuwhich might lackwin-arm64support) on an ARM64 machine, the build would fail trying to copy a non-existent file. This change safely skips the copy if the file is missing.
4. Dependency Updates
File: tools/nuget/generate_nuspec_for_native_nuget.py
- Change: Added dependency for
Microsoft.ML.OnnxRuntime.Foundrypackage.if package_name == "Microsoft.ML.OnnxRuntime.Foundry": xml_text.append('<dependency id="Microsoft.ML.OnnxRuntime.Gpu.Linux"' + ' version="' + version + '"/>')
- Impact: Ensures that consuming the Foundry package also pulls in the Linux GPU runtime.
Verification & Questions
- Confirm OSX-X64 Removal: The removal of
osx-x64support is clear in the code (generate_nuspec_for_custom_nuget.py). Just double-checking if this aligns with the Foundry package requirements. - ARM64EC vs ARM64: The switch to
arm64(native) fromarm64ecis mentioned. The pipeline changes seem to align with treating it as standardwin-arm64.
Conclusion
The changes look solid and address the stated goals. The refactoring improves maintainability, and the props.xml fix is a good quality-of-life improvement for ARM64 developers.
Review Result: Looks good.
This pull-request addresses a few issues with the Microsoft.ML.OnnxRuntime.Foundry: - Builds arm64 as opposed to previous arm64ec for windows arm64. - Signs the nuget package. - Updates target props by checking if onnxruntime.dll exists before attempting to copy. This is a bugfix where if one tries to install any non arm64 package on an arm64 machine (for example when one uses Microsoft.ML.OnnxRuntime.Gpu on windows arm64) it always tries to copy the win-arm64 onnxruntime.dll which does not exist. - Takes a dependency on Microsoft.ML.OnnxRuntime.Gpu.Linux for the foundry package.
This cherry-picks the following commits for the 1.24.2 release: - #27096 - #27077 - #26677 - #27238 - #27213 - #27256 - #27278 - #27275 - #27276 - #27216 - #27271 - #27299 - #27294 - #27266 - #27176 - #27126 - #27252 --------- Co-authored-by: Xiaofei Han <[email protected]> Co-authored-by: Jiajia Qin <[email protected]> Co-authored-by: Yulong Wang <[email protected]> Co-authored-by: qti-monumeen <[email protected]> Co-authored-by: Ankit Maheshkar <[email protected]> Co-authored-by: Eric Crawford <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: guschmue <[email protected]> Co-authored-by: Guenther Schmuelling <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: angelser <[email protected]> Co-authored-by: Angela Serrano Brummett <[email protected]> Co-authored-by: Misha Chornyi <[email protected]> Co-authored-by: hariharans29 <[email protected]> Co-authored-by: eserscor <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Baiju Meswani <[email protected]> Co-authored-by: Adrian Lizarraga <[email protected]> Co-authored-by: Ti-Tai Wang <[email protected]> Co-authored-by: bmehta001 <[email protected]>
This pull-request addresses a few issues with the Microsoft.ML.OnnxRuntime.Foundry: