Repository navigation
Expand file tree
/
Copy pathrun_all_examples.bat
More file actions
126 lines (108 loc) · 3.96 KB
/
Copy pathrun_all_examples.bat
File metadata and controls
126 lines (108 loc) · 3.96 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
@echo off
setlocal enabledelayedexpansion
echo ===============================================
echo GroupDocs.Conversion.LowCode C# Code Examples
echo ===============================================
echo.
REM Check for license keys
set "license_warning="
if "%GD_PUBLIC_KEY%"=="" (
set "license_warning=1"
echo [WARNING] GD_PUBLIC_KEY environment variable is not set
)
if "%GD_PRIVATE_KEY%"=="" (
set "license_warning=1"
echo [WARNING] GD_PRIVATE_KEY environment variable is not set
)
if defined license_warning (
echo.
echo [INFO] License keys are required for examples to work properly.
echo [INFO] Set them using: set GD_PUBLIC_KEY=your-key ^& set GD_PRIVATE_KEY=your-key
echo [INFO] Or edit the Program.cs files directly with your license keys.
echo.
set /p "continue=Do you want to continue anyway? (y/N): "
if /i not "!continue!"=="y" (
echo Aborted.
pause
exit /b 1
)
echo.
)
echo [INFO] Starting to run all GroupDocs.Conversion.LowCode examples...
echo [INFO] This will run 67 examples and skip 3 that need a license put into Program.cs.
echo [INFO] Each example will be built and run individually.
echo.
set "project_count=0"
set "success_count=0"
set "failed_count=0"
set "skipped_count=0"
echo ========================================
echo Running Examples...
echo ========================================
for /r Examples %%i in (*.csproj) do (
set /a "project_count+=1"
set "project_dir=%%~dpi"
for %%j in ("%%~dpi\.") do set "project_name=%%~nj"
echo.
echo [!project_count!] Running: !project_name!
echo Directory: !project_dir!
REM Skip examples that read a license file or keys from the code
set "own_license="
findstr /l /c:"License.Set" "%%~dpiProgram.cs" >nul 2>&1 && (findstr /l /c:"GD_PUBLIC_KEY" "%%~dpiProgram.cs" >nul 2>&1 || set "own_license=1")
if defined own_license (
echo [SKIPPED] Needs your license in Program.cs; add it and run this example with dotnet run
set /a "skipped_count+=1"
) else (
pushd "!project_dir!"
REM Try to build first
echo Building project...
dotnet build --verbosity quiet >nul 2>&1
if errorlevel 1 (
echo [ERROR] Build failed for: !project_name!
set /a "failed_count+=1"
) else (
echo Building successful, running example...
REM Capture output and check for unhandled exceptions
dotnet run --verbosity quiet > temp_output.txt 2>&1
set "run_exit_code=!errorlevel!"
REM Check if output contains "Unhandled exception"
findstr /i "Unhandled exception" temp_output.txt >nul 2>&1
if !errorlevel! equ 0 (
echo [ERROR] Unhandled exception detected in: !project_name!
echo [ERROR] Output:
type temp_output.txt
set /a "failed_count+=1"
) else if !run_exit_code! neq 0 (
echo [ERROR] Failed to run: !project_name!
echo [ERROR] Output:
type temp_output.txt
set /a "failed_count+=1"
) else (
echo [SUCCESS] Completed: !project_name!
set /a "success_count+=1"
)
REM Clean up temp file
if exist temp_output.txt del temp_output.txt
)
popd
)
)
echo.
echo ========================================
echo Summary
echo ========================================
echo Total projects found: %project_count%
echo Successful runs: %success_count%
echo Failed runs: %failed_count%
echo Skipped: %skipped_count%
if %failed_count% gtr 0 (
echo.
echo [NOTE] Some examples failed. This might be due to:
echo - Missing license keys
echo - Missing sample files
echo - .NET version compatibility
echo - File access permissions
)
echo.
echo All examples completed. Check the output above for any errors.
pause