-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_opencvsharp_runtime.ps1
More file actions
55 lines (39 loc) · 1.5 KB
/
build_opencvsharp_runtime.ps1
File metadata and controls
55 lines (39 loc) · 1.5 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
# Exit on error
$ErrorActionPreference = "Stop"
pushd
$tempProjectDir = "temp_project"
$publishDir = "publish"
if (Test-Path $publishDir) {
Remove-Item $publishDir -Recurse -Force
}
# Create a temporary project
if (Test-Path $tempProjectDir) {
Remove-Item $tempProjectDir -Recurse -Force
}
New-Item -ItemType Directory -Path $tempProjectDir | Out-Null
Set-Location $tempProjectDir
dotnet new console -n temp_project
Set-Location $tempProjectDir
# Add packages without versions
dotnet add package OpenCvSharp4.official.runtime.linux-x64.slim
dotnet add package OpenCvSharp4.official.runtime.ubuntu.24.04-x64.slim
# Build the project to get the packages into the bin directory
dotnet build
# Extract the version from the csproj file
$csprojPath = "temp_project.csproj"
$csproj = [xml](Get-Content $csprojPath)
$packageReferences = $csproj.Project.ItemGroup.PackageReference
$version = $packageReferences | Where-Object { $_.Include -like "*linux-x64.slim*" } | Select-Object -ExpandProperty Version
if (-not $version) {
Write-Error "Failed to extract package version."
exit 1
}
Write-Host "Latest version: $version"
# Update the nuspec file with the latest version
$nuspecPath = "../../straights.opencvsharp.runtime.linux.nuspec"
(Get-Content $nuspecPath) -replace '<version>.*</version>', "<version>$version</version>" | Set-Content $nuspecPath
# Build NuGet package
mkdir ../../publish
dotnet pack $nuspecPath --output ../../publish
popd
Write-Host "Done! The NuGet package is in the publish directory."