Skip to content

Add NativeAOT publish smoke test (win-x64, linux-x64, osx-arm64) - #2061

Merged
shimat merged 4 commits into
mainfrom
nativeaot-publish-smoke-test
Jul 18, 2026
Merged

Add NativeAOT publish smoke test (win-x64, linux-x64, osx-arm64)#2061
shimat merged 4 commits into
mainfrom
nativeaot-publish-smoke-test

Conversation

@shimat

@shimat shimat commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Opening as draft to watch CI on win-x64/linux-x64/osx-arm64 before marking ready.

Adds test/OpenCvSharp.Tests.NativeAot, a plain console app published with PublishAot=true that exercises drawing, the ORB/OpenCL-probe path, an ImEncode/ImDecode codec round trip, and Cv2.Dnn.BlobFromImage - the same end-to-end surface OpenCvSharp.Tests.Wasm's E2E test covers (see opencvsharp_blazor_sample#8/#11, which hit a Mono AOT compiler crash on OpenCvSharp.dll's large P/Invoke surface), but through CoreCLR's ILCompiler instead of Blazor wasm's Mono AOT compiler. Locally, win-x64 publishes and runs cleanly end-to-end against the real native binary, and linux-x64 publishes/links cleanly (not yet run against a real .so locally - too slow to build OpenCV from scratch just for this check). osx-arm64 is untested locally (no Mac available); this PR's CI run is its first real signal.

Also fixes a real NETSDK1207 failure this surfaced: OpenCvSharp.csproj's ProjectReference to the netstandard2.0 OpenCvSharp.Analyzers project was propagating PublishAot/RuntimeIdentifier down to it, which any consumer publishing with PublishAot would hit regardless of this test project.

Test plan

  • win-x64: dotnet publish -p:PublishAot=true succeeds with 0 trim/AOT warnings; published exe runs and prints ok: ... (verified locally)
  • linux-x64: same publish command succeeds inside a plain mcr.microsoft.com/dotnet/sdk:10.0-noble container with clang/zlib1g-dev installed (verified locally, link step only - not run against a real .so)
  • osx-arm64: relies on this PR's CI run
  • Watch the three CI jobs (windows.yml, docker-test-ubuntu.yml, macos.yml) added/changed here

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added end-to-end NativeAOT smoke tests for macOS, Windows, and Ubuntu environments.
    • Added coverage for drawing, feature detection, image encoding/decoding, and DNN processing.
  • Bug Fixes
    • Improved publishing compatibility by preventing incompatible build settings from reaching analyzer components.
  • Tests
    • Added the NativeAOT test project to the solution and automated build, publish, and execution checks.

shimat added 2 commits July 18, 2026 20:37
Adds test/OpenCvSharp.Tests.NativeAot, a plain console app published with
PublishAot=true that exercises drawing, the ORB/OpenCL-probe path, an
ImEncode/ImDecode codec round trip, and Cv2.Dnn.BlobFromImage - the same
end-to-end surface OpenCvSharp.Tests.Wasm's E2E test covers, but through
CoreCLR's ILCompiler instead of Blazor wasm's Mono AOT compiler.

Also fixes a real NETSDK1207 failure this surfaced: OpenCvSharp.csproj's
ProjectReference to the netstandard2.0 OpenCvSharp.Analyzers project was
propagating PublishAot/RuntimeIdentifier down to it, which any consumer
publishing with PublishAot would hit regardless of this test project.
Resolves the OpenCvSharp.sln/.slnx conflict: main migrated to the .slnx
format (#2059) while this branch still edited the old .sln, so the new
NativeAOT test project is registered in OpenCvSharp.slnx instead.
@shimat shimat self-assigned this Jul 18, 2026
shimat added 2 commits July 18, 2026 21:52
opencv_videoio_ffmpeg500_64.dll is only conditionally copied by CMake's
POST_BUILD step (guarded by an EXISTS check), so it isn't guaranteed to be
there - and this smoke test never exercises video/ffmpeg, so it was never
needed. Fixes the win-x64 CI failure from PR #2061.
…deps

A second `apt-get update` after the 1700+ test run in this Docker stage hit a
reproducible apt-get segfault (twice in a row on PR #2061's CI): apt printed
"libapt-private.so.0.0: no version information available" and then crashed
with SIGSEGV before installing anything. Root cause unconfirmed, but
consolidating into the one apt-get pass at the top of the stage (before the
heavy dotnet build/test run) sidesteps it and is cleaner regardless.
@shimat
shimat marked this pull request as ready for review July 18, 2026 15:07
@shimat
shimat merged commit dd990cd into main Jul 18, 2026
13 of 14 checks passed
@shimat
shimat deleted the nativeaot-publish-smoke-test branch July 18, 2026 15:07
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8dd8cbda-345d-402e-93be-768912dcec38

📥 Commits

Reviewing files that changed from the base of the PR and between e122d19 and b537896.

📒 Files selected for processing (7)
  • .github/workflows/macos.yml
  • .github/workflows/windows.yml
  • OpenCvSharp.slnx
  • packaging/docker/ubuntu24-dotnet10-opencv5.0.0/Dockerfile
  • src/OpenCvSharp/OpenCvSharp.csproj
  • test/OpenCvSharp.Tests.NativeAot/OpenCvSharp.Tests.NativeAot.csproj
  • test/OpenCvSharp.Tests.NativeAot/Program.cs

📝 Walkthrough

Walkthrough

Adds a net10.0 NativeAOT console smoke test covering core OpenCV operations, integrates it into the solution, configures AOT build dependencies, and runs published binaries in macOS, Windows, and Linux validation environments.

Changes

NativeAOT validation

Layer / File(s) Summary
NativeAOT test application
test/OpenCvSharp.Tests.NativeAot/*, OpenCvSharp.slnx
Adds a NativeAOT console project and solution entry. The test validates drawing, ORB detection, image encoding/decoding, and DNN blob creation.
AOT build support
src/OpenCvSharp/OpenCvSharp.csproj, packaging/docker/ubuntu24-dotnet10-opencv5.0.0/Dockerfile
Stops AOT-related properties from flowing into the analyzer project and installs Linux NativeAOT dependencies.
Cross-platform execution
.github/workflows/macos.yml, .github/workflows/windows.yml, packaging/docker/ubuntu24-dotnet10-opencv5.0.0/Dockerfile
Restores, publishes, prepares native libraries, and runs the NativeAOT executable on macOS arm64, Windows x64, and Linux.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CI
  participant dotnet
  participant NativeAOTApp
  participant OpenCvSharpExtern
  CI->>dotnet: restore NativeAOT project
  CI->>dotnet: publish with PublishAot=true
  CI->>NativeAOTApp: run published executable
  NativeAOTApp->>OpenCvSharpExtern: perform OpenCV operations
  OpenCvSharpExtern-->>NativeAOTApp: return image, ORB, and DNN results
  NativeAOTApp-->>CI: exit 0 or exit 1
Loading

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nativeaot-publish-smoke-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@shimat shimat added the enhancement New feature or improvement to OpenCvSharp label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to OpenCvSharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant