Open
Conversation
Add Microsoft.ML.OnnxRuntime.EP.WebGpu NuGet package project (netstandard2.0) with a C# helper class for cross-platform native library resolution, a test console app, a reusable pack_nuget.ps1 script, and a CI pipeline stage for building, signing, and testing the package. New files: - plugin-ep-webgpu/csharp/Microsoft.ML.OnnxRuntime.EP.WebGpu/ (.csproj, WebGpuEp.cs, README.md) - plugin-ep-webgpu/csharp/test/WebGpuEpNuGetTest/ (test app, nuget.config, mul.onnx, model generator) - plugin-ep-webgpu/csharp/pack_nuget.ps1 (reusable pack script for local and CI) - plugin-ep-webgpu/csharp/README.md (development readme) - tools/ci_build/.../stages/plugin-webgpu-nuget-packaging-stage.yml Modified: plugin-webgpu-packaging-stage.yml (wire in NuGet stage)
Pack stage: add -NuGetConfig parameter to pack_nuget.ps1 and pass the repo-root NuGet.config (locked to the 1ES feed by setup-feeds-and-python-steps.yml). The staging dir lives outside the source tree, so NuGet's upward config walk would otherwise miss the lockdown and fall back to public nuget.org, which the network policy blocks (NU1301). Test stage: pull in setup-feeds-and-python-steps.yml for the NuGet test job, and rewrite the inline nuget.config generation to add only the local feed. NuGet's hierarchical merge layers it on top of the repo-root config, giving effective sources of 1ES Feed + local. Drop the previously-checked-in project-level nuget.config (had a stale dev-only path); the pipeline generates it deterministically now.
Split pack_nuget.ps1 into -BuildOnly and -PackOnly phases so the managed Microsoft.ML.OnnxRuntime.EP.WebGpu.dll can be ESRP-signed in between, satisfying CodeSign compliance for files inside the .nupkg. Also add a -StagingDir parameter so the packaging YAML doesn't depend on script-internal layout, lift NuGetConfig validation to the top of the script, and share common pack_nuget.ps1 args between the build and pack steps via a WebGpuPackNuGetCommonArgs pipeline variable.
…y under binary_dir.
…TIME_VERSION The .csproj reads the minimum required Microsoft.ML.OnnxRuntime version from a file pointed at by the OnnxRuntimeMinVersionFile MSBuild property, defaulting to plugin-ep-webgpu/MIN_ONNXRUNTIME_VERSION. pack_nuget.ps1 overrides the property with an absolute path so the staged build still resolves it correctly.
EsrpCodeSigning@5 treats Pattern as a filename mask, not a path glob. The leading '**\' caused the task to build an invalid path '...\webgpu_pack_staging\**' and fail with an IOException. Drop the glob; the task already recurses into FolderPath.
- Add -RequiredPlatforms opt-in to pack_nuget.ps1 so CI fails fast when an expected platform's binaries are missing, while preserving dev flexibility. - Add Validate_Parameters stage to fail loudly when build_windows_arm64=true but build_windows_x64=false, instead of silently disabling arm64. - Compute and pass required platforms from the NuGet packaging stage (Python inline script). - Drop redundant explicit Microsoft.ML.OnnxRuntime PackageReference from the smoke-test csproj; rely on the EP package's transitive dependency. - Misc: README cleanup, comment consolidation, remove stale pointer comment in WebGpuEp.cs.
Replaces the PowerShell packaging script with pack_nuget.py and updates the WebGPU plugin EP NuGet packaging pipeline stage to invoke it. The Python version uses argparse with a Path-resolving converter for path arguments, raises a PackError exception for user-actionable failures, and uses tempfile.TemporaryDirectory for the unowned-staging-dir case (with --staging-dir required when --build-only or --pack-only is set).
Defer to --help to avoid drift between the script and the docs.
- pack_nuget.py: note that the netstandard2.0 path segment must match <TargetFramework> in the csproj. - README.md: replace mixed Windows/POSIX paths in the multi-platform example with <path-to-...> placeholders.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds NuGet packaging + CI integration for the WebGPU plugin EP, including a managed helper API and a CI smoke test that consumes the produced package.
Changes:
- Introduces a new
Microsoft.ML.OnnxRuntime.EP.WebGpuNuGet project plus apack_nuget.pypack/staging script. - Adds Azure Pipelines stages to pack/sign the NuGet and run a Windows GPU validation test consuming the packaged bits.
- Updates plugin docs to include C#/.NET packaging and usage information.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/ci_build/github/azure-pipelines/stages/plugin-win-webgpu-test-stage.yml | Adds a Windows CI job that restores from a local feed and runs a .NET smoke test against the produced NuGet. |
| tools/ci_build/github/azure-pipelines/stages/plugin-webgpu-packaging-stage.yml | Adds parameter validation and wires in a NuGet packaging stage after platform builds. |
| tools/ci_build/github/azure-pipelines/stages/plugin-webgpu-nuget-packaging-stage.yml | New stage to download platform artifacts, build/sign managed DLL, pack/sign NuGet. |
| plugin-ep-webgpu/python/build_wheel.py | Clarifies binary directory assumption in a comment. |
| plugin-ep-webgpu/python/README.md | Makes versioning instructions generic and updates dependency note. |
| plugin-ep-webgpu/csharp/test/WebGpuEpNuGetTest/mul.onnx | Adds a small ONNX model used by the NuGet smoke test. |
| plugin-ep-webgpu/csharp/test/WebGpuEpNuGetTest/generate_mul_model.py | Adds a script to regenerate the test model. |
| plugin-ep-webgpu/csharp/test/WebGpuEpNuGetTest/WebGpuEpNuGetTest.csproj | Adds a .NET test app that references the new package. |
| plugin-ep-webgpu/csharp/test/WebGpuEpNuGetTest/Program.cs | Implements EP registration + inference validation for CI. |
| plugin-ep-webgpu/csharp/pack_nuget.py | New script to stage native assets and run dotnet build/pack. |
| plugin-ep-webgpu/csharp/README.md | Adds build/pack/test instructions for the C# NuGet packaging flow. |
| plugin-ep-webgpu/csharp/Microsoft.ML.OnnxRuntime.EP.WebGpu/WebGpuEp.cs | Adds helper to locate the native EP library and provide EP name(s). |
| plugin-ep-webgpu/csharp/Microsoft.ML.OnnxRuntime.EP.WebGpu/README.md | Adds package README shipped in the .nupkg with usage example. |
| plugin-ep-webgpu/csharp/Microsoft.ML.OnnxRuntime.EP.WebGpu/Microsoft.ML.OnnxRuntime.EP.WebGpu.csproj | New NuGet project with min ORT version read from shared file + runtime asset packing. |
| plugin-ep-webgpu/README.md | Updates top-level plugin docs to reference shared min ORT version and C# package. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- generate_mul_model.py: use a single import style for onnx (CodeQL). - WebGpuEp.cs: use ProcessArchitecture instead of OSArchitecture so emulated processes pick the matching native asset. - README.md: simplify the usage example and note that error handling is omitted for readability. - plugin-webgpu-nuget-packaging-stage.yml: drop the unused cmake_build_type parameter; compare templated booleans case-insensitively. - WebGpuEpNuGetTest.csproj: add an OrtWebGpuPackageVersion property (default *-* for local dev) and reference it from PackageReference. - plugin-win-webgpu-test-stage.yml: extract the exact package version from the .nupkg filename and pass it through to dotnet build via -p:OrtWebGpuPackageVersion; switch dotnet build/run steps to powershell with backtick continuations.
Convert all PowerShell steps in plugin-win-webgpu-test-stage.yml to the - pwsh: shorthand for consistency. The Python test step previously used the PowerShell@2 task with pwsh: true; the NuGet test steps used the - powershell: shorthand which runs Windows PowerShell 5.1. All now run under PowerShell 7+.
- README.md: drop the null-forgiving operator from the usage example in favor of a nullable annotation. - WebGpuEp.cs: throw PlatformNotSupportedException for unsupported OS or process architecture instead of silently returning placeholder strings; rewrite GetArchTag with a switch expression. - plugin-win-webgpu-test-stage.yml: deduplicate the test csproj path via a job-level WebGpuTestProject variable; drop redundant 'clean: true' from 'checkout: self' (workspace.clean: all already covers it); tighten the .nupkg version regex to require a leading digit and add a clear error if no matching .nupkg is found.
…stage.yml invocation
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request adds C#/.NET (NuGet) packaging support for the WebGPU plugin Execution Provider, including all necessary project files, documentation, and helper code. It introduces a new NuGet package (
Microsoft.ML.OnnxRuntime.EP.WebGpu), updates the main plugin documentation to reflect C# support, and provides detailed instructions and code samples for building, packaging, and using the provider in .NET applications.The most important changes are:
C#/.NET Packaging Infrastructure:
Microsoft.ML.OnnxRuntime.EP.WebGpuproject (.csproj) for NuGet packaging, including metadata, dependency management, and logic to read the minimum ONNX Runtime version from a shared file. Native binaries are included per platform, and the README is bundled in the package.WebGpuEp.cshelper class to resolve the native library path and EP name at runtime, simplifying registration and usage in .NET.Documentation:
README.mdfor the C# package, including usage instructions, supported platforms, and example code for registering and using the WebGPU EP in .NET.csharp/README.mdwith instructions for building, packaging, and testing the NuGet package, as well as information on CI integration and native binary requirements.Motivation and Context
Create WebGPU plugin EP NuGet package.