Skip to content

fix

fix #760

Workflow file for this run

name: Windows Server 2025
on:
pull_request:
types: [synchronize, opened]
push:
branches:
- main
env:
OPENCV_VERSION: "4.13.0"
OPENCV_FILES_TAG: "4.13.0.20260207"
TESSERACT_RELEASE_VERSION: "2024.08.19"
jobs:
build:
runs-on: windows-2025
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 1
submodules: true
- name: Install .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
- name: Download OpenCV binaries
shell: powershell
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download --repo shimat/opencv_files ${env:OPENCV_FILES_TAG} --pattern "opencv_win_x64.zip"
Expand-Archive -Path opencv_win_x64.zip -DestinationPath opencv_files/opencv_win_x64 -Force -ErrorAction Stop
ls opencv_files/opencv_win_x64
- name: Download Tesseract binaries
shell: powershell
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download --repo shimat/tesseract_vcpkg ${TESSERACT_RELEASE_VERSION} --pattern "*.zip" --output tesseract.zip
Expand-Archive -Path tesseract.zip -DestinationPath tesseract_files -Force -ErrorAction Stop
ls tesseract_files
Move-Item tesseract_files/tesseract_vcpkg.0.0.9-beta tesseract_files/tesseract_vcpkg
ls tesseract_files/tesseract_vcpkg
New-Item tesseract_files/tesseract_vcpkg -ItemType Directory -Force
Move-Item tesseract_files/tesseract_vcpkg/installed/* tesseract_files/tesseract_vcpkg/
ls tesseract_files/tesseract_vcpkg
- name: NuGet restore
shell: cmd
run: nuget restore
# 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: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Build x64
shell: cmd
run: msbuild OpenCvSharp.sln /t:build /p:configuration=Release /p:platform=x64 -maxcpucount
- name: Build slim native runtime
shell: powershell
run: |
$ErrorActionPreference = "Stop"
# Compile OpenCvSharpExtern in "slim" mode by disabling selected wrapper modules.
# These NO_* macros are consumed by OpenCvSharpExtern headers.
$slimDefines = "/DNO_CONTRIB /DNO_STITCHING /DNO_VIDEO /DNO_VIDEOIO /DNO_HIGHGUI /DNO_DNN /DNO_ML /DNO_BARCODE"
$env:CL = "$slimDefines $env:CL"
# Keep slim outputs/intermediates separate from the full Release build artifacts.
$slimOut = Join-Path $env:GITHUB_WORKSPACE "src/ReleaseSlim/x64/"
$slimInt = Join-Path $env:GITHUB_WORKSPACE "src/ReleaseSlim/obj/x64/"
New-Item -Path $slimOut -ItemType Directory -Force | Out-Null
New-Item -Path $slimInt -ItemType Directory -Force | Out-Null
msbuild src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj `
/t:Rebuild `
/p:Configuration=Release `
/p:Platform=x64 `
/p:SolutionDir="${env:GITHUB_WORKSPACE}\\" `
/p:OutDir="$slimOut" `
/p:IntDir="$slimInt" `
/p:PostBuildEventUseInBuild=false `
/p:RunPostBuildEvent=Never `
-maxcpucount
$slimDll = Get-ChildItem "$slimOut" -Recurse -Filter OpenCvSharpExtern.dll | Select-Object -First 1
if (-not $slimDll) { throw "Failed to locate slim OpenCvSharpExtern.dll" }
Copy-Item $slimDll.FullName "src/Release/x64/OpenCvSharpExtern.Slim.dll" -Force
- name: Test
shell: cmd
run: dotnet test test\OpenCvSharp.Tests -c Release -f net8.0 --runtime win-x64
- name: Test Windows-only functions
shell: powershell
run: |
cd ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests.Windows
dotnet test -c Release -f net8.0-windows --runtime win-x64
- name: Test Windows-only functions (net48)
shell: powershell
run: |
cd ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests.Windows
dotnet test -c Release -f net48 --runtime win-x64
- name: Pack NuGet packages
shell: powershell
run: |
$ErrorActionPreference = "Stop"
$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.Extensions/OpenCvSharp.Extensions.csproj -c Release -o artifacts -p:Version=$version
dotnet pack src/OpenCvSharp.WpfExtensions/OpenCvSharp.WpfExtensions.csproj -c Release -o artifacts -p:Version=$version
# Pack runtime packages
dotnet pack nuget/OpenCvSharp4.runtime.win.csproj -o artifacts -p:Version=$version
dotnet pack nuget/OpenCvSharp4.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 nuget/OpenCvSharp4.Windows.csproj -o artifacts -p:Version=$version -p:PackageVersion=$version
dotnet pack nuget/OpenCvSharp4.Windows.Slim.csproj -o artifacts -p:Version=$version -p:PackageVersion=$version
- name: Run ReleaseMaker
shell: powershell
run: |
cd "${env:GITHUB_WORKSPACE}\tool\OpenCvSharp.ReleaseMaker"
dotnet run -c Release --runtime win-x64 -- "${env:GITHUB_WORKSPACE}" "${env:GITHUB_WORKSPACE}\artifacts" ${{env.OPENCV_VERSION}}
- name: Upload NuGet packages and Release packages
uses: actions/upload-artifact@v6
with:
name: packages_windows
path: ${{ github.workspace }}\artifacts