-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_samples.ps1
More file actions
105 lines (95 loc) · 4.17 KB
/
build_samples.ps1
File metadata and controls
105 lines (95 loc) · 4.17 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
#!/usr/bin/env pwsh
# build_samples.ps1 - Builds all sample apps in Samples/Samples.sln
# Determine script root
$scriptRoot = $PSScriptRoot
if (-not $scriptRoot) {
$scriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
}
Set-Location $scriptRoot
Write-Host "Working directory: $scriptRoot" -ForegroundColor Cyan
Write-Host ""
Write-Host "============================================================================" -ForegroundColor Cyan
Write-Host "NVAPIWrapper Samples Build" -ForegroundColor Cyan
Write-Host "============================================================================" -ForegroundColor Cyan
Write-Host ""
# -----------------------------------------------------------------------------
# Prerequisites
# -----------------------------------------------------------------------------
Write-Host "Checking for .NET CLI..." -ForegroundColor Yellow
try {
$dotnetPath = Get-Command dotnet -ErrorAction Stop
$dotnetVersion = & dotnet --version 2>&1
Write-Host ".NET CLI found: $($dotnetPath.Source)" -ForegroundColor Green
Write-Host ".NET version: $dotnetVersion" -ForegroundColor Green
Write-Host ""
} catch {
Write-Host "ERROR: dotnet CLI not found in PATH" -ForegroundColor Red
Write-Host "Please install .NET 10.0 SDK from https://dotnet.microsoft.com/download/dotnet/10.0" -ForegroundColor Cyan
Read-Host "Press Enter to exit"
exit 1
}
Write-Host "Checking for .NET 10.0 SDK..." -ForegroundColor Yellow
try {
$sdks = & dotnet --list-sdks 2>&1
$net10Sdk = $sdks | Where-Object { $_ -match "^10\.0\." }
if (-not $net10Sdk) {
Write-Host "ERROR: .NET 10.0 SDK not found." -ForegroundColor Red
Write-Host "Available SDKs:" -ForegroundColor Yellow
$sdks | ForEach-Object { Write-Host " $_" -ForegroundColor Gray }
Read-Host "Press Enter to exit"
exit 1
}
Write-Host ".NET 10.0 SDK found:" -ForegroundColor Green
$net10Sdk | ForEach-Object { Write-Host " $_" -ForegroundColor Green }
Write-Host ""
} catch {
Write-Host "ERROR: Failed to check .NET SDKs: $_" -ForegroundColor Red
Read-Host "Press Enter to exit"
exit 1
}
# Ensure NVAPI SDK is present (samples depend on the wrapper and SDK)
$nvapiHeaderPath = "drivers.gpu.control-library\include\nvapi_api.h"
if (-not (Test-Path $nvapiHeaderPath)) {
Write-Host "ERROR: NVAPI SDK headers not found at $nvapiHeaderPath" -ForegroundColor Red
Write-Host "Run ./prepare_nvapi.ps1 first." -ForegroundColor Yellow
Read-Host "Press Enter to exit"
exit 1
}
# -----------------------------------------------------------------------------
# Restore and build Samples solution
# -----------------------------------------------------------------------------
$samplesSolution = Join-Path $scriptRoot "Samples\Samples.sln"
if (-not (Test-Path $samplesSolution)) {
Write-Host "ERROR: Samples solution not found at $samplesSolution" -ForegroundColor Red
Read-Host "Press Enter to exit"
exit 1
}
Write-Host "Restoring NuGet packages for samples..." -ForegroundColor Cyan
try {
dotnet restore $samplesSolution
if ($LASTEXITCODE -ne 0) { throw "Restore failed with exit code $LASTEXITCODE" }
Write-Host "Restore completed." -ForegroundColor Green
Write-Host ""
} catch {
Write-Host "ERROR: Restore failed. $_" -ForegroundColor Red
Read-Host "Press Enter to exit"
exit 1
}
Write-Host "Building samples..." -ForegroundColor Cyan
try {
dotnet build $samplesSolution --configuration Debug --no-restore
if ($LASTEXITCODE -ne 0) { throw "Build failed with exit code $LASTEXITCODE" }
Write-Host ""
Write-Host "============================================================================" -ForegroundColor Green
Write-Host "*** SAMPLES BUILD SUCCESSFUL! ***" -ForegroundColor Green
Write-Host "============================================================================" -ForegroundColor Green
Write-Host ""
Write-Host "Artifacts:" -ForegroundColor Cyan
Write-Host " - Samples/**/bin/Debug/net10.0" -ForegroundColor Gray
} catch {
Write-Host ""
Write-Host "ERROR: Samples build failed. $_" -ForegroundColor Red
Read-Host "Press Enter to exit"
exit 1
}
Read-Host "Press Enter to exit..."