| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- param(
- [switch]$RunBuild
- )
- # Post-build helper (Steam求购 custom edition / dakehu):
- # Copies release EXE to SteamQG.exe. Does NOT overwrite steamSH_V*.exe or SteamSH_Portable.zip.
- Set-StrictMode -Version Latest
- $repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
- Set-Location $repoRoot
- if ($RunBuild) {
- Write-Output "Running npm install and tauri windows build..."
- npm install
- npm run tauri:build:windows
- }
- # Prefer known app binary names, then largest exe > 15MB (skip installer/setup)
- $searchDirs = @(
- "$repoRoot\src-tauri\target\release",
- "$repoRoot\src-tauri\target\x86_64-pc-windows-msvc\release"
- )
- $foundExe = $null
- foreach ($dir in $searchDirs) {
- if (-not (Test-Path $dir)) { continue }
- foreach ($name in @("steamSH.exe", "your-app-name.exe")) {
- $p = Join-Path $dir $name
- if (Test-Path $p) {
- $item = Get-Item $p
- if ($item.Length -gt 15MB) {
- $foundExe = $item
- break
- }
- }
- }
- if ($foundExe) { break }
- $candidate = Get-ChildItem -Path $dir -Filter *.exe -File -ErrorAction SilentlyContinue |
- Where-Object { $_.Name -notmatch 'setup|bundle|uninstall|installer|SteamQG' -and $_.Length -gt 15MB } |
- Sort-Object Length -Descending |
- Select-Object -First 1
- if ($candidate) {
- $foundExe = $candidate
- break
- }
- }
- if (-not $foundExe) {
- Write-Error "No app executable (>15MB) found under release dirs"
- Exit 1
- }
- $destName = 'SteamQG.exe'
- $destPath = Join-Path $foundExe.DirectoryName $destName
- $rootDestPath = Join-Path $repoRoot $destName
- Try {
- Copy-Item -Path $foundExe.FullName -Destination $destPath -Force
- Write-Output "Copied '$($foundExe.Name)' ($([math]::Round($foundExe.Length/1MB,2)) MB) -> '$destName' in $($foundExe.DirectoryName)"
- Copy-Item -Path $foundExe.FullName -Destination $rootDestPath -Force
- Write-Output "Copied -> '$destName' in $repoRoot"
- Write-Output "Note: old artifacts steamSH_V*.exe / SteamSH_Portable.zip were NOT modified"
- } Catch {
- Write-Error "Failed to copy exe: $($_.Exception.Message)"
- Exit 1
- }
- Exit 0
|