Files
AndroidDeviceStreaming/scripts/build-desktop.ps1
T

28 lines
1.4 KiB
PowerShell

param(
[string]$Runtime = 'win-x64',
[switch]$FrameworkDependent
)
$ErrorActionPreference = 'Stop'
$projectRoot = Split-Path $PSScriptRoot -Parent
$outputDirectory = Join-Path $projectRoot "bin/desktop-$Runtime"
$selfContained = if ($FrameworkDependent) { 'false' } else { 'true' }
Push-Location (Join-Path $projectRoot 'desktop')
try {
dotnet publish Ads.Desktop -c Release -r $Runtime --self-contained $selfContained -o $outputDirectory --nologo
if ($LASTEXITCODE -ne 0) { throw 'Desktop publish failed' }
} finally { Pop-Location }
$suffix = if ($Runtime.StartsWith('win-')) { '.exe' } else { '' }
foreach ($toolName in @('ads-client', 'ads-usb', 'adsctl', 'ads-agent')) {
$client = Join-Path $projectRoot ('bin/' + $toolName + $suffix)
if (Test-Path -LiteralPath $client) {
Copy-Item -LiteralPath $client -Destination (Join-Path $outputDirectory ($toolName + $suffix)) -Force
}
}
if ($Runtime.StartsWith('win-') -and (Test-Path -LiteralPath (Join-Path $projectRoot 'bin/tools/scrcpy/scrcpy.exe'))) {
$tools = Join-Path $outputDirectory 'tools/scrcpy'
New-Item -ItemType Directory -Force -Path $tools | Out-Null
Copy-Item -Path (Join-Path $projectRoot 'bin/tools/scrcpy/*') -Destination $tools -Recurse -Force
}
# Do not copy client.env or any other credential into a distributable directory.
Write-Host "Desktop published to $outputDirectory (credentials excluded)"