-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_all_examples.ps1
More file actions
111 lines (97 loc) · 4.62 KB
/
Copy pathrun_all_examples.ps1
File metadata and controls
111 lines (97 loc) · 4.62 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
# PowerShell script to run all GroupDocs.Conversion.LowCode code examples
Write-Host "=============================================" -ForegroundColor Cyan
Write-Host "GroupDocs.Conversion.LowCode C# Code Examples" -ForegroundColor Cyan
Write-Host "=============================================" -ForegroundColor Cyan
Write-Host ""
# Check for license keys
$licenseWarning = $false
if (-not $env:GD_PUBLIC_KEY) {
Write-Host "[WARNING] GD_PUBLIC_KEY environment variable is not set" -ForegroundColor Yellow
$licenseWarning = $true
}
if (-not $env:GD_PRIVATE_KEY) {
Write-Host "[WARNING] GD_PRIVATE_KEY environment variable is not set" -ForegroundColor Yellow
$licenseWarning = $true
}
if ($licenseWarning) {
Write-Host ""
Write-Host "[INFO] License keys are required for examples to work properly." -ForegroundColor White
Write-Host "[INFO] Set them using: `$env:GD_PUBLIC_KEY='your-key'; `$env:GD_PRIVATE_KEY='your-key'" -ForegroundColor White
Write-Host "[INFO] Or edit the Program.cs files directly with your license keys." -ForegroundColor White
Write-Host ""
$continue = Read-Host "Do you want to continue anyway? (y/N)"
if ($continue -ne "y" -and $continue -ne "Y") {
Write-Host "Aborted." -ForegroundColor Red
exit 1
}
Write-Host ""
}
Write-Host "[INFO] Starting to run all GroupDocs.Conversion.LowCode examples..." -ForegroundColor Green
Write-Host "[INFO] This will execute 70+ examples demonstrating various conversion features." -ForegroundColor White
Write-Host "[INFO] Each example will be built and run individually." -ForegroundColor White
Write-Host ""
$projectCount = 0
$successCount = 0
$failedCount = 0
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Running Examples..." -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Get-ChildItem -Recurse -Filter "*.csproj" | ForEach-Object {
$projectCount++
$projectDir = $_.Directory.FullName
$projectName = $_.Directory.Name
Write-Host ""
Write-Host "[$projectCount] Running: $projectName" -ForegroundColor Yellow
Write-Host " Directory: $projectDir" -ForegroundColor Gray
Push-Location $projectDir
try {
# Try to build first
Write-Host " Building project..." -ForegroundColor Gray
$buildResult = dotnet build --verbosity quiet 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " [ERROR] Build failed for: $projectName" -ForegroundColor Red
$failedCount++
} else {
Write-Host " Building successful, running example..." -ForegroundColor Gray
# Capture output and check for unhandled exceptions
$runResult = dotnet run --verbosity quiet 2>&1
$runExitCode = $LASTEXITCODE
# Check if output contains "Unhandled exception"
if ($runResult -match "Unhandled exception") {
Write-Host " [ERROR] Unhandled exception detected in: $projectName" -ForegroundColor Red
Write-Host " [ERROR] Output:" -ForegroundColor Red
$runResult | ForEach-Object { Write-Host " $_" -ForegroundColor Red }
$failedCount++
} elseif ($runExitCode -ne 0) {
Write-Host " [ERROR] Failed to run: $projectName" -ForegroundColor Red
Write-Host " [ERROR] Output:" -ForegroundColor Red
$runResult | ForEach-Object { Write-Host " $_" -ForegroundColor Red }
$failedCount++
} else {
Write-Host " [SUCCESS] Completed: $projectName" -ForegroundColor Green
$successCount++
}
}
}
catch {
Write-Host " [ERROR] Exception occurred: $($_.Exception.Message)" -ForegroundColor Red
$failedCount++
}
finally {
Pop-Location
}
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Summary" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Total projects found: $projectCount" -ForegroundColor White
Write-Host "Successful runs: $successCount" -ForegroundColor Green
Write-Host "Failed runs: $failedCount" -ForegroundColor $(if ($failedCount -gt 0) { "Red" } else { "Green" })
if ($failedCount -gt 0) {
Write-Host ""
Write-Host "[TIP] Check individual example README.md files for specific requirements." -ForegroundColor Cyan
}
Write-Host ""
Write-Host "All examples completed. Check the output above for any errors." -ForegroundColor White
Read-Host "Press Enter to continue"