-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
530 lines (468 loc) · 24.8 KB
/
Copy pathwindows.yml
File metadata and controls
530 lines (468 loc) · 24.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
name: Windows Server 2025
on:
workflow_dispatch:
inputs:
run_binskim:
description: 'Run BinSkim security hardening check'
type: boolean
default: true
pull_request:
types: [synchronize, opened]
push:
branches:
- main
env:
OPENCV_VERSION: "5.0.0"
OPENCV_ARM64_CACHE_REVISION: "2"
MEDIAMTX_VERSION: "1.19.3"
MEDIAMTX_SHA256: "5d82148d1032a6a190d9909a2997d9989457aaadf49af87dd02cd4512d31bebe"
jobs:
build:
name: Windows (x64)
runs-on: windows-2025
steps:
- name: Checkout
uses: actions/checkout@v7
with:
submodules: true
fetch-depth: 1
- name: Install .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: |
10.0.x
- name: Restore vcpkg packages cache
id: vcpkg-cache
uses: actions/cache/restore@v6
with:
path: ${{ github.workspace }}/vcpkg_installed
key: vcpkg-${{ hashFiles('vcpkg.json', 'cmake/triplets/*.cmake') }}-x64-windows-static
- name: Update vcpkg to match builtin-baseline
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
run: |
$baseline = (Get-Content vcpkg.json | ConvertFrom-Json).'builtin-baseline'
git -C $env:VCPKG_INSTALLATION_ROOT fetch --depth=1 origin $baseline
git -C $env:VCPKG_INSTALLATION_ROOT checkout $baseline
& "$env:VCPKG_INSTALLATION_ROOT/bootstrap-vcpkg.bat" -disableMetrics
- name: Install vcpkg dependencies
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
run: vcpkg install --triplet x64-windows-static --overlay-triplets=${{ github.workspace }}/cmake/triplets --x-install-root=${{ github.workspace }}/vcpkg_installed
- name: Save vcpkg packages cache
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: ${{ github.workspace }}/vcpkg_installed
key: vcpkg-${{ hashFiles('vcpkg.json', 'cmake/triplets/*.cmake') }}-x64-windows-static
- name: Restore OpenCV cache
id: opencv-cache
uses: actions/cache/restore@v6
with:
path: ${{ github.workspace }}/opencv_artifacts
key: opencv-${{ env.OPENCV_VERSION }}-windows-x64-${{ hashFiles('cmake/opencv_build_options.cmake') }}-${{ hashFiles('vcpkg.json', 'cmake/triplets/*.cmake') }}
- name: Configure OpenCV
if: steps.opencv-cache.outputs.cache-hit != 'true'
shell: powershell
run: |
$ErrorActionPreference = 'Continue'
# Force OpenCV 5's vendored MLAS off by giving CMake no ASM compiler
# (see -D CMAKE_ASM_COMPILER below). MinGW or Strawberry-Perl gcc on the
# runner PATH would otherwise be picked by MLAS's check_language(ASM),
# building GNU-syntax .S SGEMM kernels that fail the MSVC link (x64:
# missing SgemmKernelSse2.obj) and inject pthread into the OpenCV link
# interface (arm64: LNK1181 pthread.lib). MLAS then disables and DNN uses
# its built-in SGEMM, matching a clean local VS build. Windows builds the
# image codecs via vcpkg, so no other ASM language is needed.
cmake `
-C cmake/opencv_build_options.cmake `
-S opencv `
-B opencv/build `
-G "Visual Studio 18 2026" -A x64 `
-D CMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" `
-D VCPKG_TARGET_TRIPLET=x64-windows-static `
-D VCPKG_MANIFEST_INSTALL=OFF `
-D "VCPKG_INSTALLED_DIR=$env:GITHUB_WORKSPACE/vcpkg_installed" `
-D "VCPKG_OVERLAY_TRIPLETS=$env:GITHUB_WORKSPACE/cmake/triplets" `
-D OPENCV_EXTRA_MODULES_PATH="$env:GITHUB_WORKSPACE/opencv_contrib/modules" `
-D CMAKE_INSTALL_PREFIX="$env:GITHUB_WORKSPACE/opencv_artifacts" `
-D CMAKE_ASM_COMPILER="" `
*>&1 | Tee-Object -FilePath "$env:TEMP\opencv-configure.log"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Verify OpenCV cmake features
if: steps.opencv-cache.outputs.cache-hit != 'true'
shell: powershell
run: |
$log = Get-Content "$env:TEMP\opencv-configure.log" -Raw
$features = @('Tesseract', 'FFMPEG', 'JPEG', 'PNG', 'TIFF', 'WEBP')
$fail = $false
foreach ($f in $features) {
$m = [regex]::Match($log, "(?m)^--\s+${f}:\s+(.+)$")
if ($m.Success -and $m.Groups[1].Value.Trim() -notmatch '^NO\b') {
Write-Host "OK: $f = $($m.Groups[1].Value.Trim())"
} else {
Write-Host "MISSING or DISABLED: $f"
$log -split "`n" | Select-String -Pattern $f | Select-Object -Last 3 | ForEach-Object { Write-Host $_ }
$fail = $true
}
}
if ($fail) { exit 1 }
- name: Build OpenCV
if: steps.opencv-cache.outputs.cache-hit != 'true'
shell: powershell
run: |
cmake --build opencv/build --config Release -j 4
cmake --install opencv/build --config Release
- name: Save OpenCV cache
if: steps.opencv-cache.outputs.cache-hit != 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/cache/save@v6
with:
path: ${{ github.workspace }}/opencv_artifacts
key: opencv-${{ env.OPENCV_VERSION }}-windows-x64-${{ hashFiles('cmake/opencv_build_options.cmake') }}-${{ hashFiles('vcpkg.json', 'cmake/triplets/*.cmake') }}
# Commented out: FFmpeg backend is included in opencv_videoio_ffmpeg DLLs
# If video tests fail, uncomment this step
#- name: Install Server-Media-Foundation
# shell: powershell
# run: |
# Install-WindowsFeature Server-Media-Foundation
- name: Build OpenCvSharpExtern (full)
shell: powershell
run: |
$ErrorActionPreference = "Stop"
cmake `
-S src `
-B src/build `
-G "Visual Studio 18 2026" -A x64 `
-D CMAKE_PREFIX_PATH="$env:GITHUB_WORKSPACE/opencv_artifacts" `
-D CMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" `
-D VCPKG_TARGET_TRIPLET=x64-windows-static `
-D VCPKG_MANIFEST_INSTALL=OFF `
-D "VCPKG_INSTALLED_DIR=$env:GITHUB_WORKSPACE/vcpkg_installed" `
-D "VCPKG_OVERLAY_TRIPLETS=$env:GITHUB_WORKSPACE/cmake/triplets"
cmake --build src/build --config Release -j 4
- name: Verify FFmpeg plugin deployment
shell: pwsh
run: |
$ffmpegPlugin = "test\OpenCvSharp.Tests\opencv_videoio_ffmpeg500_64.dll"
if (-not (Test-Path $ffmpegPlugin)) {
throw "OpenCV FFmpeg plugin was not deployed to the test project: $ffmpegPlugin"
}
- name: Build OpenCvSharpExtern (slim)
shell: powershell
run: |
$ErrorActionPreference = "Stop"
cmake `
-S src `
-B src/build_slim `
-G "Visual Studio 18 2026" -A x64 `
-D CMAKE_PREFIX_PATH="$env:GITHUB_WORKSPACE/opencv_artifacts" `
-D CMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" `
-D VCPKG_TARGET_TRIPLET=x64-windows-static `
-D VCPKG_MANIFEST_INSTALL=OFF `
-D "VCPKG_INSTALLED_DIR=$env:GITHUB_WORKSPACE/vcpkg_installed" `
-D "VCPKG_OVERLAY_TRIPLETS=$env:GITHUB_WORKSPACE/cmake/triplets" `
-D NO_CONTRIB=ON `
-D NO_VIDEOIO=ON `
-D NO_HIGHGUI=ON `
-D NO_DNN=ON `
-D NO_STITCHING=ON `
-D NO_INSTALL_TO_TEST=ON
cmake --build src/build_slim --config Release -j 4
- name: Test
shell: cmd
# The MTP crash dump extension collects a full memory dump and a test sequence file into
# test\OpenCvSharp.Tests\TestResults\ if the test host crashes, so an
# intermittent native access violation can be attributed to a specific test without a
# re-run. See "Upload crash dumps on failure" below.
run: dotnet test --project test\OpenCvSharp.Tests\OpenCvSharp.Tests.csproj -c Release -f net10.0 --runtime win-x64 --results-directory test\OpenCvSharp.Tests\TestResults --crashdump --crashdump-type Full
- name: Test RTSP capture
uses: ./.github/actions/test-rtsp-windows
with:
mediamtx-version: ${{ env.MEDIAMTX_VERSION }}
mediamtx-sha256: ${{ env.MEDIAMTX_SHA256 }}
- name: Upload crash dumps on failure
if: failure()
uses: actions/upload-artifact@v7
with:
name: windows-x64-crash-dumps
path: test/OpenCvSharp.Tests/TestResults/
if-no-files-found: ignore
- name: Test Windows-only functions
shell: powershell
run: |
cd ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests.Windows
dotnet test --project OpenCvSharp.Tests.Windows.csproj -c Release -f net10.0-windows --runtime win-x64
- name: Test Avalonia extensions
shell: powershell
run: |
cd ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests.Avalonia
# --runtime here (matching the dotnet test call below) makes the build land in a
# RID-specific bin\Release\net10.0\win-x64\ subfolder; copy into that exact folder.
dotnet build -c Release -f net10.0 --runtime win-x64
Copy-Item ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests\OpenCvSharpExtern.dll bin\Release\net10.0\win-x64\
dotnet test --project OpenCvSharp.Tests.Avalonia.csproj -c Release -f net10.0 --runtime win-x64 --no-build
- name: Test NativeAOT publish
shell: powershell
run: |
$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
# Some ILCompiler versions resolve link.exe via a bare `vswhere.exe` call, which requires
# the VS Installer directory on PATH - not guaranteed for a plain (non-"Developer") shell.
$env:Path += ";${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer"
cd ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests.NativeAot
# Restore and publish as separate steps: NuGet's static graph restore evaluates
# OpenCvSharp.Analyzers.csproj (a netstandard2.0 analyzer, referenced with
# UndefineProperties so the *build* graph never sees PublishAot/RuntimeIdentifier) under
# the raw command-line global properties regardless of that item metadata, so passing
# -p:PublishAot=true to a combined restore+publish invocation still fails restore with
# NETSDK1207. Restoring without it first, then publishing with --no-restore, avoids that.
dotnet restore -r win-x64
dotnet publish -c Release -f net10.0 --runtime win-x64 -p:PublishAot=true --no-restore
# Only OpenCvSharpExtern.dll is needed: this smoke test never touches video/ffmpeg, and
# opencv_videoio_ffmpeg500_64.dll is only conditionally copied by CMake's POST_BUILD step
# in the first place (see OpenCvSharpExtern/CMakeLists.txt's `if(EXISTS ...)` guard), so
# it is not guaranteed to exist here.
$publishDir = "bin\Release\net10.0\win-x64\publish"
Copy-Item ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests\OpenCvSharpExtern.dll $publishDir
& "$publishDir\OpenCvSharp.Tests.NativeAot.exe"
if ($LASTEXITCODE -ne 0) { throw "NativeAOT smoke test failed with exit code $LASTEXITCODE" }
- name: Verify security hardening with BinSkim
if: inputs.run_binskim == true
shell: powershell
run: |
# Official install: download .nupkg from NuGet, unzip, run exe from tools/
$dest = "$env:TEMP\binskim"
Invoke-WebRequest "https://www.nuget.org/api/v2/package/Microsoft.CodeAnalysis.BinSkim" -OutFile "$dest.zip"
Expand-Archive "$dest.zip" $dest -Force
$binskimExe = Get-ChildItem "$dest\tools\net*\win-x64\binskim.exe" | Select-Object -Last 1 -ExpandProperty FullName
if (-not $binskimExe) { throw "binskim.exe not found" }
# Scan OpenCvSharpExtern.dll only.
# opencv_videoio_ffmpeg*.dll is a pre-built binary from opencv_3rdparty
# and cannot be recompiled with different flags (see opencv/3rdparty/ffmpeg/ffmpeg.cmake).
$dll = "$env:GITHUB_WORKSPACE\src\build\OpenCvSharpExtern\Release\OpenCvSharpExtern.dll"
if (-not (Test-Path $dll)) { throw "OpenCvSharpExtern.dll not found: $dll" }
$sarifFile = "$env:TEMP\binskim.sarif"
& $binskimExe analyze $dll --output $sarifFile
# Ignore BinSkim's own exit code (it returns 1 on PDB load failures etc.);
# rely solely on SARIF result filtering below.
$LASTEXITCODE = 0
# Ignore findings we cannot address:
# ERR997 - PDB unavailable (Release builds have no PDB by default)
# BA2007 - compiler warning level violations in vcpkg static libs (tesseract, tiff, etc.)
if (-not (Test-Path $sarifFile)) { Write-Warning "No SARIF output produced."; exit 0 }
$failures = (Get-Content $sarifFile | ConvertFrom-Json).runs[0].results | Where-Object {
$ruleId = ($_.ruleId -split "/")[0]
$_.level -eq "error" -and $ruleId -notmatch "^ERR997" -and $ruleId -ne "BA2007"
}
if ($failures) {
$failures | ForEach-Object { Write-Host "FAIL $($_.ruleId): $(($_.message.text -split "`n")[0])" }
exit 1
}
Write-Host "Security hardening verified: no actionable failures."
- name: Pack NuGet packages
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
$date = Get-Date -Format "yyyyMMdd"
$version = "${env:OPENCV_VERSION}.${date}-beta"
Write-Host "version = ${version}"
# Pack main libraries (dotnet pack triggers build implicitly)
dotnet pack src/OpenCvSharp/OpenCvSharp.csproj -c Release -o artifacts -p:Version=$version
dotnet pack src/OpenCvSharp.GdipExtensions/OpenCvSharp.GdipExtensions.csproj -c Release -o artifacts -p:Version=$version
dotnet pack src/OpenCvSharp.WpfExtensions/OpenCvSharp.WpfExtensions.csproj -c Release -o artifacts -p:Version=$version
dotnet pack src/OpenCvSharp.AvaloniaExtensions/OpenCvSharp.AvaloniaExtensions.csproj -c Release -o artifacts -p:Version=$version
# Pack runtime packages
dotnet pack packaging/nuget/OpenCvSharp5.runtime.win.csproj -o artifacts -p:Version=$version
dotnet pack packaging/nuget/OpenCvSharp5.runtime.win.slim.csproj -o artifacts -p:Version=$version
# Add local artifacts as NuGet source for meta-package
dotnet nuget add source "${env:GITHUB_WORKSPACE}\artifacts" --name LocalPackages
# Pack meta-package (depends on packages built above)
dotnet pack packaging/nuget/OpenCvSharp5.Windows.csproj -o artifacts -p:Version=$version -p:PackageVersion=$version
dotnet pack packaging/nuget/OpenCvSharp5.Windows.Slim.csproj -o artifacts -p:Version=$version -p:PackageVersion=$version
- name: Upload NuGet packages
uses: actions/upload-artifact@v7
with:
name: packages_windows
path: ${{ github.workspace }}\artifacts
build-arm64:
name: Windows (arm64)
runs-on: windows-11-arm
steps:
- name: Checkout
uses: actions/checkout@v7
with:
submodules: true
fetch-depth: 1
- name: Install .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: |
10.0.x
- name: Restore vcpkg packages cache
id: vcpkg-cache
uses: actions/cache/restore@v6
with:
path: ${{ github.workspace }}/vcpkg_installed
key: vcpkg-${{ hashFiles('vcpkg.json', 'cmake/triplets/*.cmake') }}-arm64-windows-static
- name: Update vcpkg to match builtin-baseline
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
run: |
$baseline = (Get-Content vcpkg.json | ConvertFrom-Json).'builtin-baseline'
git -C $env:VCPKG_INSTALLATION_ROOT fetch --depth=1 origin $baseline
git -C $env:VCPKG_INSTALLATION_ROOT checkout $baseline
& "$env:VCPKG_INSTALLATION_ROOT/bootstrap-vcpkg.bat" -disableMetrics
- name: Install vcpkg dependencies
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
run: vcpkg install --triplet arm64-windows-static --overlay-triplets=${{ github.workspace }}/cmake/triplets --x-install-root=${{ github.workspace }}/vcpkg_installed
- name: Save vcpkg packages cache
if: steps.vcpkg-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: ${{ github.workspace }}/vcpkg_installed
key: vcpkg-${{ hashFiles('vcpkg.json', 'cmake/triplets/*.cmake') }}-arm64-windows-static
- name: Restore OpenCV cache
id: opencv-cache
uses: actions/cache/restore@v6
with:
path: ${{ github.workspace }}/opencv_artifacts
key: opencv-${{ env.OPENCV_VERSION }}-windows-arm64-v${{ env.OPENCV_ARM64_CACHE_REVISION }}-${{ hashFiles('cmake/opencv_build_options.cmake') }}-${{ hashFiles('vcpkg.json', 'cmake/triplets/*.cmake') }}
- name: Configure OpenCV
if: steps.opencv-cache.outputs.cache-hit != 'true'
shell: powershell
run: |
$ErrorActionPreference = 'Continue'
# Force OpenCV 5's vendored MLAS off by giving CMake no ASM compiler
# (see -D CMAKE_ASM_COMPILER below). MinGW or Strawberry-Perl gcc on the
# runner PATH would otherwise be picked by MLAS's check_language(ASM),
# building GNU-syntax .S SGEMM kernels that fail the MSVC link (x64:
# missing SgemmKernelSse2.obj) and inject pthread into the OpenCV link
# interface (arm64: LNK1181 pthread.lib). MLAS then disables and DNN uses
# its built-in SGEMM, matching a clean local VS build. Windows builds the
# image codecs via vcpkg, so no other ASM language is needed.
# OpenCV 5's vendored MLAS uses GNU-syntax aarch64 .S SGEMM kernels that
# armasm64 (the only ASM compiler on the VS2022 ARM64 toolchain, which
# windows-11-arm ships instead of VS2026) cannot assemble, and
# CMAKE_ASM_COMPILER="" does not disable ASM under the VS ARM64 generator
# (it does under VS2026 x64). MLAS is an OpenCV 5 addition (absent in
# OpenCV 4), so skip building it on this toolchain; DNN keeps working via
# its built-in SGEMM (as OpenCV 4 ARM64 did). Drop the add_subdirectory
# that pulls MLAS into opencv_dnn.
(Get-Content opencv/modules/dnn/CMakeLists.txt) `
-replace 'add_subdirectory\("\$\{OpenCV_SOURCE_DIR\}/3rdparty/mlas".*', '# [win-arm64] MLAS disabled (armasm64 cannot assemble its aarch64 .S kernels)' `
| Set-Content opencv/modules/dnn/CMakeLists.txt
cmake `
-C cmake/opencv_build_options.cmake `
-S opencv `
-B opencv/build `
-G "Visual Studio 17 2022" -A ARM64 `
-D CMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" `
-D VCPKG_TARGET_TRIPLET=arm64-windows-static `
-D VCPKG_MANIFEST_INSTALL=OFF `
-D "VCPKG_INSTALLED_DIR=$env:GITHUB_WORKSPACE/vcpkg_installed" `
-D "VCPKG_OVERLAY_TRIPLETS=$env:GITHUB_WORKSPACE/cmake/triplets" `
-D OPENCV_EXTRA_MODULES_PATH="$env:GITHUB_WORKSPACE/opencv_contrib/modules" `
-D CMAKE_INSTALL_PREFIX="$env:GITHUB_WORKSPACE/opencv_artifacts" `
-D WITH_FFMPEG=OFF `
-D CMAKE_C_FLAGS="/Z7" `
-D CMAKE_CXX_FLAGS="/Z7" `
-D CMAKE_ASM_COMPILER="" `
*>&1 | Tee-Object -FilePath "$env:TEMP\opencv-configure.log"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Verify OpenCV cmake features
if: steps.opencv-cache.outputs.cache-hit != 'true'
shell: powershell
run: |
$log = Get-Content "$env:TEMP\opencv-configure.log" -Raw
$features = @('Tesseract', 'JPEG', 'PNG', 'TIFF', 'WEBP')
$fail = $false
foreach ($f in $features) {
$m = [regex]::Match($log, "(?m)^--\s+${f}:\s+(.+)$")
if ($m.Success -and $m.Groups[1].Value.Trim() -notmatch '^NO\b') {
Write-Host "OK: $f = $($m.Groups[1].Value.Trim())"
} else {
Write-Host "MISSING or DISABLED: $f"
$log -split "`n" | Select-String -Pattern $f | Select-Object -Last 3 | ForEach-Object { Write-Host $_ }
$fail = $true
}
}
if ($fail) { exit 1 }
- name: Build OpenCV
if: steps.opencv-cache.outputs.cache-hit != 'true'
shell: powershell
run: |
cmake --build opencv/build --config Release -j 4
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
cmake --install opencv/build --config Release
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Save OpenCV cache
if: steps.opencv-cache.outputs.cache-hit != 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/cache/save@v6
with:
path: ${{ github.workspace }}/opencv_artifacts
key: opencv-${{ env.OPENCV_VERSION }}-windows-arm64-v${{ env.OPENCV_ARM64_CACHE_REVISION }}-${{ hashFiles('cmake/opencv_build_options.cmake') }}-${{ hashFiles('vcpkg.json', 'cmake/triplets/*.cmake') }}
- name: Build OpenCvSharpExtern (full)
shell: powershell
run: |
$ErrorActionPreference = "Stop"
cmake `
-S src `
-B src/build_arm64 `
-G "Visual Studio 17 2022" -A ARM64 `
-D CMAKE_PREFIX_PATH="$env:GITHUB_WORKSPACE/opencv_artifacts" `
-D CMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" `
-D VCPKG_TARGET_TRIPLET=arm64-windows-static `
-D VCPKG_MANIFEST_INSTALL=OFF `
-D "VCPKG_INSTALLED_DIR=$env:GITHUB_WORKSPACE/vcpkg_installed" `
-D "VCPKG_OVERLAY_TRIPLETS=$env:GITHUB_WORKSPACE/cmake/triplets" `
-D OPENCVSHARP_BUILD_WITH_DEBUG_INFO=ON
cmake --build src/build_arm64 --config Release -j 4
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Build OpenCvSharpExtern (slim)
shell: powershell
run: |
$ErrorActionPreference = "Stop"
cmake `
-S src `
-B src/build_arm64_slim `
-G "Visual Studio 17 2022" -A ARM64 `
-D CMAKE_PREFIX_PATH="$env:GITHUB_WORKSPACE/opencv_artifacts" `
-D CMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" `
-D VCPKG_TARGET_TRIPLET=arm64-windows-static `
-D VCPKG_MANIFEST_INSTALL=OFF `
-D "VCPKG_INSTALLED_DIR=$env:GITHUB_WORKSPACE/vcpkg_installed" `
-D "VCPKG_OVERLAY_TRIPLETS=$env:GITHUB_WORKSPACE/cmake/triplets" `
-D NO_CONTRIB=ON `
-D NO_VIDEOIO=ON `
-D NO_HIGHGUI=ON `
-D NO_DNN=ON `
-D NO_STITCHING=ON `
-D NO_INSTALL_TO_TEST=ON
cmake --build src/build_arm64_slim --config Release -j 4
- name: Test
shell: cmd
# See the x64 job's "Test" step above for why crash dump collection is enabled here.
run: dotnet test --project test\OpenCvSharp.Tests\OpenCvSharp.Tests.csproj -c Release -f net10.0 --runtime win-arm64 --filter-not-method OpenCvSharp.Tests.Core.BuildConfigurationTest.FFMPEG_IsEnabled --results-directory test\OpenCvSharp.Tests\TestResults --crashdump --crashdump-type Full
- name: Upload crash dumps on failure
if: failure()
uses: actions/upload-artifact@v7
with:
name: windows-arm64-crash-diagnostics
path: |
src/build_arm64/OpenCvSharpExtern/Release/OpenCvSharpExtern.dll
src/build_arm64/OpenCvSharpExtern/Release/OpenCvSharpExtern.pdb
test/OpenCvSharp.Tests/TestResults/
if-no-files-found: ignore
- name: Pack NuGet packages
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
$date = Get-Date -Format "yyyyMMdd"
$version = "${env:OPENCV_VERSION}.${date}-beta"
Write-Host "version = ${version}"
dotnet pack packaging/nuget/OpenCvSharp5.runtime.win-arm64.csproj -o artifacts -p:Version=$version
dotnet pack packaging/nuget/OpenCvSharp5.runtime.win-arm64.slim.csproj -o artifacts -p:Version=$version
- name: Upload NuGet packages
uses: actions/upload-artifact@v7
with:
name: packages_windows_arm64
path: ${{ github.workspace }}\artifacts