130 lines
5.9 KiB
PowerShell
130 lines
5.9 KiB
PowerShell
<#
|
|
NetDesk by Akronlogic -- PORTABLE build + staging script.
|
|
|
|
Builds the release viewer (cargo build --release -p netdesk-viewer) with the
|
|
MinGW GNU toolchain on PATH, then assembles a self-contained portable folder
|
|
(NetDesk.exe + NetDeskHost.exe host engine + the 3 MinGW runtime DLLs +
|
|
README) and zips it. No install needed -- the user unzips it anywhere and
|
|
runs NetDesk.exe from the folder. One app = full host + remote-control viewer.
|
|
|
|
Outputs land in packaging\dist\ :
|
|
NetDesk-Portable\ (staging folder, also consumed by the installer)
|
|
NetDesk-Portable-win64.zip (the portable artifact)
|
|
|
|
Usage:
|
|
powershell -ExecutionPolicy Bypass -File build-portable.ps1
|
|
powershell -ExecutionPolicy Bypass -File build-portable.ps1 -SkipBuild # reuse existing exe
|
|
#>
|
|
[CmdletBinding()]
|
|
param(
|
|
[string]$MingwBin = "C:\mingw-netdesk\mingw64\bin",
|
|
[string]$CargoBin = (Join-Path $env:USERPROFILE ".cargo\bin"),
|
|
[switch]$SkipBuild
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
# ---- paths -----------------------------------------------------------------
|
|
$PkgDir = $PSScriptRoot
|
|
$RootDir = Split-Path -Parent $PkgDir
|
|
$DistDir = Join-Path $PkgDir "dist"
|
|
$StageDir = Join-Path $DistDir "NetDesk-Portable"
|
|
$ZipPath = Join-Path $DistDir "NetDesk-Portable-win64.zip"
|
|
$ExeSrc = Join-Path $RootDir "target\x86_64-pc-windows-gnu\release\netdesk-viewer.exe"
|
|
|
|
$Dlls = @("libstdc++-6.dll", "libgcc_s_seh-1.dll", "libwinpthread-1.dll")
|
|
|
|
Write-Host "=== NetDesk portable build (Akronlogic) ===" -ForegroundColor Cyan
|
|
Write-Host "root : $RootDir"
|
|
Write-Host "dist : $DistDir"
|
|
|
|
# ---- 1. build --------------------------------------------------------------
|
|
if (-not $SkipBuild) {
|
|
if (-not (Test-Path (Join-Path $MingwBin "gcc.exe"))) {
|
|
throw "MinGW toolchain not found at '$MingwBin' (no gcc.exe). Pass -MingwBin <path> or install it."
|
|
}
|
|
$env:PATH = "$MingwBin;$CargoBin;$env:PATH"
|
|
Write-Host "`n[1/4] cargo build --release -p netdesk-viewer" -ForegroundColor Yellow
|
|
Push-Location $RootDir
|
|
try {
|
|
& cargo build --release -p netdesk-viewer --target x86_64-pc-windows-gnu
|
|
if ($LASTEXITCODE -ne 0) { throw "cargo build failed (exit $LASTEXITCODE)" }
|
|
} finally {
|
|
Pop-Location
|
|
}
|
|
} else {
|
|
Write-Host "`n[1/4] -SkipBuild set: reusing existing binary" -ForegroundColor Yellow
|
|
}
|
|
|
|
if (-not (Test-Path $ExeSrc)) { throw "viewer binary not found: $ExeSrc" }
|
|
|
|
# ---- 2. assemble staging folder -------------------------------------------
|
|
Write-Host "[2/4] assembling portable folder: $StageDir" -ForegroundColor Yellow
|
|
if (Test-Path $StageDir) { Remove-Item $StageDir -Recurse -Force }
|
|
New-Item -ItemType Directory -Path $StageDir -Force | Out-Null
|
|
|
|
# viewer renamed to the product name
|
|
Copy-Item $ExeSrc (Join-Path $StageDir "NetDesk.exe") -Force
|
|
|
|
# the 3 MinGW runtime DLLs beside the exe
|
|
foreach ($d in $Dlls) {
|
|
$src = Join-Path $MingwBin $d
|
|
if (-not (Test-Path $src)) { throw "missing runtime DLL: $src" }
|
|
Copy-Item $src (Join-Path $StageDir $d) -Force
|
|
}
|
|
|
|
# NOTE: NetDesk is now ONE pure-Rust binary. Start Service runs the native host
|
|
# engine (DXGI capture + hardware H.264 + SendInput) IN-PROCESS, so there is no
|
|
# separate NetDeskHost.exe to bundle any more — NetDesk.exe + the 3 runtime DLLs
|
|
# are the whole app (host panel + remote-control viewer).
|
|
|
|
# ---- 3. README.txt ---------------------------------------------------------
|
|
# Built from an array of lines (no here-string: Windows PowerShell 5.1
|
|
# mis-parses here-strings in LF-only script files). Joined with CRLF and
|
|
# written BOM-less so Notepad and every editor render it cleanly.
|
|
Write-Host "[3/4] writing README.txt" -ForegroundColor Yellow
|
|
$readmeLines = @(
|
|
'NetDesk -- Portable Edition (Full Client)',
|
|
'Developed by Akronlogic (https://akronlogic.com)',
|
|
'',
|
|
'NetDesk is ONE unified app. It is both the HOST (let someone control this PC)',
|
|
'and the remote-control VIEWER (control another PC) -- a full client, like',
|
|
'TeamViewer. Open it, and the home screen is your host panel; enter a Partner',
|
|
'ID to connect out and it becomes the viewer.',
|
|
'',
|
|
'HOW TO RUN',
|
|
' 1. Unzip this folder anywhere you like (Desktop, a USB stick, etc.).',
|
|
' 2. Double-click NetDesk.exe.',
|
|
' There is nothing to install and no admin rights are required. Keep every',
|
|
' file in this folder together -- NetDesk.exe needs the three *.dll files',
|
|
' beside it to run.',
|
|
'',
|
|
'WHAT''S IN THIS FOLDER',
|
|
' NetDesk.exe The NetDesk full client (host engine + viewer, all in one).',
|
|
' libstdc++-6.dll MinGW C++ runtime (required).',
|
|
' libgcc_s_seh-1.dll MinGW GCC runtime (required).',
|
|
' libwinpthread-1.dll MinGW threading runtime (required).',
|
|
' README.txt This file.',
|
|
'',
|
|
'NOTES',
|
|
' * Connects to the NetDesk server (netdesk.space) using the existing protocol.',
|
|
' * To remove NetDesk, just delete this folder. Nothing is written elsewhere.',
|
|
' * Prefer a Start Menu entry / Desktop shortcut + uninstaller? Use the',
|
|
' installer edition (NetDesk-Setup-win64.exe) instead.',
|
|
'',
|
|
'(c) Akronlogic. All rights reserved.'
|
|
)
|
|
$readme = ($readmeLines -join "`r`n") + "`r`n"
|
|
[System.IO.File]::WriteAllText((Join-Path $StageDir "README.txt"), $readme, (New-Object System.Text.UTF8Encoding($false)))
|
|
|
|
# ---- 4. zip ----------------------------------------------------------------
|
|
Write-Host "[4/4] zipping -> $ZipPath" -ForegroundColor Yellow
|
|
if (Test-Path $ZipPath) { Remove-Item $ZipPath -Force }
|
|
Compress-Archive -Path (Join-Path $StageDir "*") -DestinationPath $ZipPath -CompressionLevel Optimal
|
|
|
|
$zi = Get-Item $ZipPath
|
|
Write-Host "`nPortable build complete." -ForegroundColor Green
|
|
Write-Host (" zip : {0}" -f $zi.FullName)
|
|
Write-Host (" size : {0:N0} bytes ({1:N2} MB)" -f $zi.Length, ($zi.Length/1MB))
|
|
Write-Host (" stage : {0}" -f $StageDir)
|