Skip to content

Remove net48 as a direct build target #751

Remove net48 as a direct build target

Remove net48 as a direct build target #751

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-native:
name: build-native (${{ matrix.arch }})
runs-on: windows-2025
strategy:
matrix:
include:
- arch: x64
vcxproj_platform: x64
ffmpeg_dll_src: opencv_files/opencv_win_x64/x64/vc17/bin/opencv_videoio_ffmpeg4130_64.dll
- arch: x86
vcxproj_platform: Win32
ffmpeg_dll_src: opencv_files/opencv_win_x86/x86/vc17/bin/opencv_videoio_ffmpeg4130.dll
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 1
submodules: true
- 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_${{ matrix.arch }}.zip"
Expand-Archive -Path opencv_win_${{ matrix.arch }}.zip -DestinationPath opencv_files/opencv_win_${{ matrix.arch }} -Force -ErrorAction Stop
ls opencv_files/opencv_win_${{ matrix.arch }}
- 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 ${{ matrix.arch }}
shell: cmd
run: msbuild OpenCvSharp.sln /t:build /p:configuration=Release /p:platform=${{ matrix.arch }} -maxcpucount
- name: Build slim native runtime (${{ matrix.arch }})
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/${{ matrix.vcxproj_platform }}/"
$slimInt = Join-Path $env:GITHUB_WORKSPACE "src/ReleaseSlim/obj/${{ matrix.vcxproj_platform }}/"
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=${{ matrix.vcxproj_platform }} `
/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/${{ matrix.vcxproj_platform }}/OpenCvSharpExtern.Slim.dll" -Force
- name: Install .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
- name: Build managed libraries
if: matrix.arch == 'x64'
shell: cmd
run: |
dotnet build src/OpenCvSharp.Extensions/OpenCvSharp.Extensions.csproj -f net8.0 -p:configuration=Release -maxcpucount
dotnet build src/OpenCvSharp.WpfExtensions/OpenCvSharp.WpfExtensions.csproj -f net8.0-windows -p:configuration=Release -maxcpucount
- name: Test
shell: powershell
run: |
cd ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests
dotnet test -c Release -f net8.0 --runtime win-${{ matrix.arch }}
- 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-${{ matrix.arch }}
- 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-${{ matrix.arch }}
- name: Upload native DLLs
uses: actions/upload-artifact@v4
with:
name: native-dlls-${{ matrix.arch }}
path: |
src/Release/${{ matrix.vcxproj_platform }}/OpenCvSharpExtern.dll
src/Release/${{ matrix.vcxproj_platform }}/OpenCvSharpExtern.Slim.dll
${{ matrix.ffmpeg_dll_src }}
pack:
runs-on: windows-2025
needs: build-native
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 1
submodules: true
- name: Download x64 native DLLs
uses: actions/download-artifact@v4
with:
name: native-dlls-x64
path: native-dlls-x64
- name: Download x86 native DLLs
uses: actions/download-artifact@v4
with:
name: native-dlls-x86
path: native-dlls-x86
- name: Place DLLs in expected locations
shell: powershell
run: |
$ErrorActionPreference = "Stop"
New-Item -Path "src/Release/x64" -ItemType Directory -Force | Out-Null
New-Item -Path "src/Release/Win32" -ItemType Directory -Force | Out-Null
New-Item -Path "opencv_files/opencv_win_x64/x64/vc17/bin" -ItemType Directory -Force | Out-Null
New-Item -Path "opencv_files/opencv_win_x86/x86/vc17/bin" -ItemType Directory -Force | Out-Null
# Full and slim DLLs
Copy-Item "native-dlls-x64/src/Release/x64/OpenCvSharpExtern.dll" "src/Release/x64/" -Force
Copy-Item "native-dlls-x64/src/Release/x64/OpenCvSharpExtern.Slim.dll" "src/Release/x64/" -Force
Copy-Item "native-dlls-x86/src/Release/Win32/OpenCvSharpExtern.dll" "src/Release/Win32/" -Force
Copy-Item "native-dlls-x86/src/Release/Win32/OpenCvSharpExtern.Slim.dll" "src/Release/Win32/" -Force
# FFmpeg DLLs (required by runtime.win NuGet packages)
Copy-Item "native-dlls-x64/opencv_files/opencv_win_x64/x64/vc17/bin/opencv_videoio_ffmpeg4130_64.dll" `
"opencv_files/opencv_win_x64/x64/vc17/bin/" -Force
Copy-Item "native-dlls-x86/opencv_files/opencv_win_x86/x86/vc17/bin/opencv_videoio_ffmpeg4130.dll" `
"opencv_files/opencv_win_x86/x86/vc17/bin/" -Force
- name: Install .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
- 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