# Run after `npm run tauri build`. Copies OpenSSL DLLs next to the release exe and builds dist-portable/ for distribution. # NSIS cannot be re-run without Tauri's plugin path; use dist-portable or install OpenSSL on target PCs. $ErrorActionPreference = "Stop" function Get-OpenSslBinDir { if ($env:OPENSSL_ROOT) { $b = Join-Path $env:OPENSSL_ROOT "bin" if (Test-Path (Join-Path $b "libcrypto-3-x64.dll")) { return $b } } foreach ($p in @( "C:\Program Files\OpenSSL-Win64\bin", "C:\Program Files (x86)\OpenSSL-Win64\bin" )) { if (Test-Path (Join-Path $p "libcrypto-3-x64.dll")) { return $p } } return $null } $ProjectRoot = Split-Path -Parent $PSScriptRoot $ReleaseDir = Join-Path $ProjectRoot "src-tauri\target\release" $PortableDir = Join-Path $ProjectRoot "dist-portable" if (-not (Test-Path $ReleaseDir)) { Write-Host "ERROR: $ReleaseDir not found. Run npm run tauri build first." -ForegroundColor Red exit 1 } $sslBin = Get-OpenSslBinDir if (-not $sslBin) { Write-Host "ERROR: libcrypto-3-x64.dll not found." -ForegroundColor Red Write-Host "Install OpenSSL Win64 FULL from https://slproweb.com/products/Win32OpenSSL.html or set OPENSSL_ROOT." exit 1 } $crypto = Join-Path $sslBin "libcrypto-3-x64.dll" $sslDll = Join-Path $sslBin "libssl-3-x64.dll" if (-not (Test-Path $sslDll)) { Write-Host "ERROR: libssl-3-x64.dll missing in $sslBin" -ForegroundColor Red exit 1 } Copy-Item $crypto $ReleaseDir -Force Copy-Item $sslDll $ReleaseDir -Force Write-Host "Copied OpenSSL DLLs to $ReleaseDir" $mainExe = Get-ChildItem $ReleaseDir -Filter "*.exe" -File -ErrorAction SilentlyContinue | Sort-Object Length -Descending | Select-Object -First 1 if (-not $mainExe) { Write-Host "WARN: No main exe found in release root; skipped dist-portable." -ForegroundColor Yellow exit 0 } New-Item -ItemType Directory -Path $PortableDir -Force | Out-Null Copy-Item $mainExe.FullName $PortableDir -Force Copy-Item $crypto $PortableDir -Force Copy-Item $sslDll $PortableDir -Force $readme = @( "Buff client (portable folder)", "", "Copy EVERY file in this folder to the same directory on the target PC, then run the exe.", "Do not copy only the exe; OpenSSL DLLs are required.", "", "Files:", " - $($mainExe.Name)", " - libcrypto-3-x64.dll", " - libssl-3-x64.dll" ) -join [Environment]::NewLine Set-Content -Path (Join-Path $PortableDir "README-portable.txt") -Value $readme -Encoding UTF8 Write-Host "" Write-Host "Portable folder ready: $PortableDir" -ForegroundColor Green Write-Host "Distribute the entire dist-portable directory (exe + 2 dlls + README-portable.txt)."