function Build-CustomRustDesk { [CmdletBinding()] param( [Parameter(Mandatory = $true)] [string]$Version, [Parameter(Mandatory = $true)] [string]$ConfigPath, [Parameter(Mandatory = $true)] [string]$OutputDir, [Parameter(Mandatory = $true)] [string]$BuilderCommandTemplate ) if (-not (Test-Path -LiteralPath $ConfigPath)) { throw "Config file not found: $ConfigPath" } New-Item -Path $OutputDir -ItemType Directory -Force | Out-Null $resolvedConfig = Resolve-Path -LiteralPath $ConfigPath $resolvedOutput = Resolve-Path -LiteralPath $OutputDir $command = $BuilderCommandTemplate $command = $command.Replace("{{version}}", $Version) $command = $command.Replace("{{config}}", $resolvedConfig.Path) $command = $command.Replace("{{output}}", $resolvedOutput.Path) Write-Host "Executing builder command:" Write-Host $command Invoke-Expression $command if ($LASTEXITCODE -ne 0) { throw "Custom builder command failed with exit code $LASTEXITCODE" } }