Skip to content

Commit b892979

Browse files
committed
🏗️ update deploy script to run on both voiceattacks
1 parent e1940ef commit b892979

1 file changed

Lines changed: 112 additions & 28 deletions

File tree

deploy-plugin.ps1

Lines changed: 112 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,143 @@
11
#!/usr/bin/env pwsh
22

33
param(
4-
[string]$DestinationPath = "C:\Program Files (x86)\Steam\steamapps\common\VoiceAttack 2\Apps\EliteAPI",
5-
[switch]$SkipVoiceAttackRestart
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
612
)
713

814
# Detect if running on Windows
915
$IsWindowsOS = ($PSVersionTable.PSVersion.Major -lt 6) -or ($IsWindows -eq $true)
1016

11-
Write-Host "Stopping VoiceAttack..." -ForegroundColor Cyan
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+
)
1254

13-
if (-not $SkipVoiceAttackRestart -and $IsWindowsOS) {
14-
try {
15-
Stop-Process -Name "VoiceAttack" -Force -ErrorAction SilentlyContinue
16-
Write-Host "VoiceAttack stopped." -ForegroundColor Green
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
1770
}
18-
catch {
19-
Write-Host "VoiceAttack was not running." -ForegroundColor Yellow
71+
else {
72+
Write-Error "Build output not found at: $buildOutputPath"
73+
return $false
2074
}
2175

22-
Start-Sleep -Seconds 2
76+
return $true
2377
}
2478

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
2593
Write-Host "`nBuilding plugin..." -ForegroundColor Cyan
26-
dotnet clean "EliteVA/EliteVA.csproj" -c Debug
94+
dotnet clean "EliteVA/EliteVA.csproj" -c Debug | Out-Null
2795
dotnet build "EliteVA/EliteVA.csproj" -c Debug
2896

2997
if ($LASTEXITCODE -ne 0) {
3098
Write-Error "Build failed!"
3199
exit 1
32100
}
33101

34-
Write-Host "`nCopying plugin files..." -ForegroundColor Cyan
102+
Write-Host "Build successful." -ForegroundColor Green
35103

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
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+
}
39111
}
40112

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
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
45122
}
46123

47-
Write-Host "Plugin deployed successfully." -ForegroundColor Green
124+
# Start VoiceAttack for testing
125+
if (-not $SkipRestart -and -not $NoTest) {
126+
Write-Host "`nStarting VoiceAttack for testing..." -ForegroundColor Cyan
48127

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
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"
55131
}
56-
else {
57-
Write-Warning "VoiceAttack.exe not found at: $voiceAttackExe"
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
58140
}
59141
}
142+
143+
Write-Host "`nDone!" -ForegroundColor Green

0 commit comments

Comments
 (0)