|
1 | 1 | #!/usr/bin/env pwsh |
2 | 2 |
|
3 | 3 | param( |
4 | | - [ValidateSet("VA1", "VA2", "Both")] |
5 | | - [string]$Version = "Both", |
6 | | - |
7 | | - [string]$VA1Path = "C:\Program Files (x86)\Steam\steamapps\common\VoiceAttack\Apps\EliteAPI", |
8 | | - [string]$VA2Path = "C:\Program Files (x86)\Steam\steamapps\common\VoiceAttack 2\Apps\EliteAPI", |
9 | | - |
10 | | - [switch]$SkipRestart, |
11 | | - [switch]$NoTest |
| 4 | + [string]$DestinationPath = "C:\Program Files (x86)\Steam\steamapps\common\VoiceAttack 2\Apps\EliteAPI", |
| 5 | + [switch]$SkipVoiceAttackRestart |
12 | 6 | ) |
13 | 7 |
|
14 | 8 | # Detect if running on Windows |
15 | 9 | $IsWindowsOS = ($PSVersionTable.PSVersion.Major -lt 6) -or ($IsWindows -eq $true) |
16 | 10 |
|
17 | | -function Stop-VoiceAttackProcess { |
18 | | - param([string]$ProcessName) |
19 | | - |
20 | | - if ($IsWindowsOS) { |
21 | | - try { |
22 | | - $process = Get-Process -Name $ProcessName -ErrorAction SilentlyContinue |
23 | | - if ($process) { |
24 | | - Stop-Process -Name $ProcessName -Force -ErrorAction SilentlyContinue |
25 | | - Write-Host "Stopped $ProcessName." -ForegroundColor Green |
26 | | - Start-Sleep -Seconds 2 |
27 | | - } |
28 | | - } |
29 | | - catch { |
30 | | - Write-Host "$ProcessName was not running." -ForegroundColor Yellow |
31 | | - } |
32 | | - } |
33 | | -} |
34 | | - |
35 | | -function Start-VoiceAttackProcess { |
36 | | - param([string]$ExePath, [string]$Name) |
37 | | - |
38 | | - if ($IsWindowsOS -and (Test-Path $ExePath)) { |
39 | | - Write-Host "Starting $Name..." -ForegroundColor Cyan |
40 | | - Start-Process $ExePath |
41 | | - Write-Host "$Name started." -ForegroundColor Green |
42 | | - } |
43 | | - else { |
44 | | - Write-Warning "$Name not found at: $ExePath" |
45 | | - } |
46 | | -} |
47 | | - |
48 | | -function Deploy-Plugin { |
49 | | - param( |
50 | | - [string]$TargetFramework, |
51 | | - [string]$DestinationPath, |
52 | | - [string]$Name |
53 | | - ) |
| 11 | +Write-Host "Stopping VoiceAttack..." -ForegroundColor Cyan |
54 | 12 |
|
55 | | - Write-Host "`nDeploying to $Name ($TargetFramework)..." -ForegroundColor Cyan |
56 | | - |
57 | | - # Create destination directory if it doesn't exist |
58 | | - if (-not (Test-Path $DestinationPath)) { |
59 | | - New-Item -ItemType Directory -Path $DestinationPath -Force | Out-Null |
60 | | - } |
61 | | - |
62 | | - # Copy all items from build output to destination |
63 | | - $buildOutputPath = "EliteVA/bin/Debug/$TargetFramework/" |
64 | | - if (Test-Path $buildOutputPath) { |
65 | | - Get-ChildItem -Path $buildOutputPath -Filter *.dll | ForEach-Object { |
66 | | - Copy-Item $_.FullName -Destination $DestinationPath -Force |
67 | | - Write-Host " Copied $($_.Name)" -ForegroundColor Gray |
68 | | - } |
69 | | - Write-Host "$Name deployment complete." -ForegroundColor Green |
| 13 | +if (-not $SkipVoiceAttackRestart -and $IsWindowsOS) { |
| 14 | + try { |
| 15 | + Stop-Process -Name "VoiceAttack" -Force -ErrorAction SilentlyContinue |
| 16 | + Write-Host "VoiceAttack stopped." -ForegroundColor Green |
70 | 17 | } |
71 | | - else { |
72 | | - Write-Error "Build output not found at: $buildOutputPath" |
73 | | - return $false |
| 18 | + catch { |
| 19 | + Write-Host "VoiceAttack was not running." -ForegroundColor Yellow |
74 | 20 | } |
75 | 21 |
|
76 | | - return $true |
| 22 | + Start-Sleep -Seconds 2 |
77 | 23 | } |
78 | 24 |
|
79 | | -# Stop VoiceAttack instances |
80 | | -if (-not $SkipRestart) { |
81 | | - Write-Host "Stopping VoiceAttack instances..." -ForegroundColor Cyan |
82 | | - |
83 | | - if ($Version -eq "VA1" -or $Version -eq "Both") { |
84 | | - Stop-VoiceAttackProcess -ProcessName "VoiceAttack" |
85 | | - } |
86 | | - |
87 | | - if ($Version -eq "VA2" -or $Version -eq "Both") { |
88 | | - Stop-VoiceAttackProcess -ProcessName "VoiceAttack" |
89 | | - } |
90 | | -} |
91 | | - |
92 | | -# Build plugin |
93 | 25 | Write-Host "`nBuilding plugin..." -ForegroundColor Cyan |
94 | | -dotnet clean "EliteVA/EliteVA.csproj" -c Debug | Out-Null |
| 26 | +dotnet clean "EliteVA/EliteVA.csproj" -c Debug |
95 | 27 | dotnet build "EliteVA/EliteVA.csproj" -c Debug |
96 | 28 |
|
97 | 29 | if ($LASTEXITCODE -ne 0) { |
98 | 30 | Write-Error "Build failed!" |
99 | 31 | exit 1 |
100 | 32 | } |
101 | 33 |
|
102 | | -Write-Host "Build successful." -ForegroundColor Green |
| 34 | +Write-Host "`nCopying plugin files..." -ForegroundColor Cyan |
103 | 35 |
|
104 | | -# Deploy to selected version(s) |
105 | | -$deploySuccess = $true |
106 | | - |
107 | | -if ($Version -eq "VA1" -or $Version -eq "Both") { |
108 | | - if (-not (Deploy-Plugin -TargetFramework "net48" -DestinationPath $VA1Path -Name "VoiceAttack 1")) { |
109 | | - $deploySuccess = $false |
110 | | - } |
| 36 | +# Create destination directory if it doesn't exist |
| 37 | +if (-not (Test-Path $DestinationPath)) { |
| 38 | + New-Item -ItemType Directory -Path $DestinationPath -Force | Out-Null |
111 | 39 | } |
112 | 40 |
|
113 | | -if ($Version -eq "VA2" -or $Version -eq "Both") { |
114 | | - if (-not (Deploy-Plugin -TargetFramework "net8.0" -DestinationPath $VA2Path -Name "VoiceAttack 2")) { |
115 | | - $deploySuccess = $false |
116 | | - } |
117 | | -} |
118 | | - |
119 | | -if (-not $deploySuccess) { |
120 | | - Write-Error "Deployment failed for one or more versions!" |
121 | | - exit 1 |
| 41 | +# Copy all items from build output to destination |
| 42 | +$buildOutputPath = "EliteVA/bin/Debug/net8.0/" |
| 43 | +Get-ChildItem -Path $buildOutputPath -Filter *.dll | ForEach-Object { |
| 44 | + Copy-Item $_.FullName -Destination $DestinationPath -Force |
122 | 45 | } |
123 | 46 |
|
124 | | -# Start VoiceAttack for testing |
125 | | -if (-not $SkipRestart -and -not $NoTest) { |
126 | | - Write-Host "`nStarting VoiceAttack for testing..." -ForegroundColor Cyan |
| 47 | +Write-Host "Plugin deployed successfully." -ForegroundColor Green |
127 | 48 |
|
128 | | - if ($Version -eq "VA1") { |
129 | | - $va1Exe = "C:\Program Files (x86)\Steam\steamapps\common\VoiceAttack\VoiceAttack.exe" |
130 | | - Start-VoiceAttackProcess -ExePath $va1Exe -Name "VoiceAttack 1" |
| 49 | +if (-not $SkipVoiceAttackRestart -and $IsWindowsOS) { |
| 50 | + Write-Host "`nStarting VoiceAttack..." -ForegroundColor Cyan |
| 51 | + $voiceAttackExe = "C:\Program Files (x86)\Steam\steamapps\common\VoiceAttack 2\VoiceAttack.exe" |
| 52 | + if (Test-Path $voiceAttackExe) { |
| 53 | + Start-Process $voiceAttackExe |
| 54 | + Write-Host "Done!" -ForegroundColor Green |
131 | 55 | } |
132 | | - elseif ($Version -eq "VA2") { |
133 | | - $va2Exe = "C:\Program Files (x86)\Steam\steamapps\common\VoiceAttack 2\VoiceAttack.exe" |
134 | | - Start-VoiceAttackProcess -ExePath $va2Exe -Name "VoiceAttack 2" |
135 | | - } |
136 | | - elseif ($Version -eq "Both") { |
137 | | - Write-Host "`nBoth versions deployed. Start manually to test:" -ForegroundColor Yellow |
138 | | - Write-Host " VA1: $(Join-Path (Split-Path $VA1Path -Parent) 'VoiceAttack.exe')" -ForegroundColor Gray |
139 | | - Write-Host " VA2: C:\Program Files (x86)\Steam\steamapps\common\VoiceAttack 2\VoiceAttack.exe" -ForegroundColor Gray |
| 56 | + else { |
| 57 | + Write-Warning "VoiceAttack.exe not found at: $voiceAttackExe" |
140 | 58 | } |
141 | 59 | } |
142 | | - |
143 | | -Write-Host "`nDone!" -ForegroundColor Green |
0 commit comments