<# .SYNOPSIS Build Codename 206 and install the VST3 (and CLAP) into the system plugin folders. .DESCRIPTION FL Studio scans `C:\Program Files\Common Files\VST3` by default and ignores directory junctions, so deployment must place a REAL bundle copy there. That folder needs admin, so the copy step self-elevates (one UAC prompt). After deploying, in FL Studio: Options -> Manage plugins -> tick "Rescan previously failed plugins" -> "Find installed plugins". .PARAMETER SkipBuild Install the existing target\bundled output without rebuilding. .PARAMETER User Install to the per-user folder %LOCALAPPDATA%\Programs\Common\VST3 instead of the global one. No admin required; add that path in FL's plugin search paths. .EXAMPLE .\deploy.ps1 # build + install to global VST3/CLAP (UAC prompt) .\deploy.ps1 -SkipBuild # reinstall last build .\deploy.ps1 -User # no-admin install for a fast dev loop #> param( [switch]$SkipBuild, [switch]$User, [string]$Package = "codename_206" ) $ErrorActionPreference = "Stop" $root = Split-Path -Parent $MyInvocation.MyCommand.Path # rustup installs cargo here; make sure it's reachable even in a fresh shell. $cargoBin = Join-Path $env:USERPROFILE ".cargo\bin" if (Test-Path $cargoBin) { $env:Path = "$cargoBin;$env:Path" } if (-not $SkipBuild) { Write-Host "Building $Package (release)..." -ForegroundColor Cyan Push-Location $root try { cargo xtask bundle $Package --release } finally { Pop-Location } if ($LASTEXITCODE -ne 0) { throw "cargo xtask bundle failed (exit $LASTEXITCODE)" } } $vst3Name = "Codename 206.vst3" $clapName = "Codename 206.clap" $bundled = Join-Path $root "target\bundled" $vst3Src = Join-Path $bundled $vst3Name $clapSrc = Join-Path $bundled $clapName if (-not (Test-Path $vst3Src)) { throw "Bundle not found: $vst3Src (build first)" } if ($User) { $vst3Dst = Join-Path $env:LOCALAPPDATA "Programs\Common\VST3" $clapDst = Join-Path $env:LOCALAPPDATA "Programs\Common\CLAP" New-Item -ItemType Directory -Force -Path $vst3Dst, $clapDst | Out-Null Write-Host "Installing (per-user, no admin)..." -ForegroundColor Cyan Remove-Item (Join-Path $vst3Dst $vst3Name) -Recurse -Force -ErrorAction SilentlyContinue Copy-Item $vst3Src -Destination $vst3Dst -Recurse -Force if (Test-Path $clapSrc) { Copy-Item $clapSrc -Destination $clapDst -Force } Write-Host "Installed to $vst3Dst" -ForegroundColor Green Write-Host "Add that folder to FL's plugin search paths if you haven't." -ForegroundColor Yellow } else { $vst3Dst = Join-Path $env:CommonProgramFiles "VST3" $clapDst = Join-Path $env:CommonProgramFiles "CLAP" Write-Host "Installing to $vst3Dst (requires admin - accept the UAC prompt)..." -ForegroundColor Cyan $cmd = @" New-Item -ItemType Directory -Force -Path '$clapDst' | Out-Null Remove-Item -LiteralPath '$vst3Dst\$vst3Name' -Recurse -Force -ErrorAction SilentlyContinue Copy-Item -LiteralPath '$vst3Src' -Destination '$vst3Dst' -Recurse -Force if (Test-Path -LiteralPath '$clapSrc') { Copy-Item -LiteralPath '$clapSrc' -Destination '$clapDst' -Force } "@ $enc = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($cmd)) Start-Process powershell -Verb RunAs -Wait -ArgumentList '-NoProfile','-EncodedCommand',$enc } # Verify each bundle was actually refreshed. A plugin currently loaded in a DAW keeps its # binary locked, so the copy fails silently and leaves a STALE install — re-scanning then runs # old code. Compare install vs build timestamps to catch exactly that. function Test-Installed($label, $src, $dst) { if (-not (Test-Path $src)) { return } # nothing was built for this format if (-not (Test-Path $dst)) { throw "$label install verification failed: $dst not found" } $srcT = (Get-Item $src).LastWriteTime $dstT = (Get-Item $dst).LastWriteTime if ($dstT -lt $srcT) { Write-Warning "$label is STALE (installed $dstT < built $srcT). It's almost certainly loaded in your DAW (file locked). Close the plugin/DAW and re-run deploy." } else { Write-Host "$label installed OK -> $dst" -ForegroundColor Green } } Test-Installed "VST3" (Join-Path $vst3Src "Contents\x86_64-win\$vst3Name") (Join-Path $vst3Dst "$vst3Name\Contents\x86_64-win\$vst3Name") Test-Installed "CLAP" $clapSrc (Join-Path $clapDst $clapName) Write-Host "In FL Studio: Manage plugins -> 'Rescan previously failed plugins' -> Find installed plugins." -ForegroundColor Yellow