@@ -25,18 +25,58 @@ jobs:
2525 shell : pwsh
2626
2727 - name : Install MetaTrader5
28+ shell : pwsh
2829 run : |
29- $installArgs = @(
30- "/S",
31- "/portable=$env:GITHUB_WORKSPACE\MT5Portable",
32- "/skipupdate"
33- )
34- Start-Process "$env:GITHUB_WORKSPACE\mt5setup.exe" -ArgumentList $installArgs -Wait -NoNewWindow
35- if (-not (Test-Path "$env:GITHUB_WORKSPACE\MT5Portable\terminal64.exe")) {
36- Write-Error "Installation failed - terminal.exe not found"
37- exit 1
30+ $installDir = "$env:GITHUB_WORKSPACE\MT5Portable"
31+
32+ # Clean previous installations
33+ if (Test-Path $installDir) {
34+ Remove-Item -Recurse -Force $installDir
3835 }
39- shell : pwsh
36+
37+ # Verify installer exists
38+ if (-not (Test-Path "$env:GITHUB_WORKSPACE\mt5setup.exe")) {
39+ Write-Error "Installer not found!"
40+ exit 1
41+ }
42+
43+ # Run installer with timeout
44+ $process = Start-Process "$env:GITHUB_WORKSPACE\mt5setup.exe" `
45+ -ArgumentList @(
46+ "/S",
47+ "/portable=$installDir",
48+ "/skipupdate"
49+ ) `
50+ -PassThru `
51+ -NoNewWindow
52+
53+ try {
54+ # Wait with timeout (120 seconds)
55+ if (-not $process.WaitForExit(120000)) {
56+ Write-Error "Installer timed out after 2 minutes"
57+ Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue
58+ exit 1
59+ }
60+
61+ # Verify exit code
62+ if ($process.ExitCode -ne 0) {
63+ Write-Error "Installer failed with exit code $($process.ExitCode)"
64+ exit 1
65+ }
66+ }
67+ catch {
68+ Write-Error "Installation error: $_"
69+ exit 1
70+ }
71+
72+ # Verify installation
73+ if (-not (Test-Path "$installDir\terminal64.exe")) {
74+ Get-ChildItem $installDir -Recurse | Out-Host
75+ Write-Error "Installation verification failed"
76+ exit 1
77+ }
78+
79+ Write-Host "MT5 installed successfully in $installDir"
4080
4181 - name : Launch MetaTrader5
4282 run : |
0 commit comments