| 1 | # Build Cage-owned assets only. Third-party Windows packages are fetched when |
| 2 | # Windows is selected, with the digests in windows-workbench-packages.json. |
| 3 | [CmdletBinding()] |
| 4 | param([Parameter(Mandatory)][string]$Destination) |
| 5 | $ErrorActionPreference='Stop' |
| 6 | $root=(Resolve-Path (Join-Path $PSScriptRoot '../..')).Path |
| 7 | $dest=[IO.Path]::GetFullPath($Destination) |
| 8 | $null=New-Item -ItemType Directory -Force $dest |
| 9 | $build=Join-Path ([IO.Path]::GetTempPath()) ('cage-windows-publish-'+[guid]::NewGuid()) |
| 10 | Push-Location $root |
| 11 | $oldOS=$env:GOOS; $oldArch=$env:GOARCH; $oldCGO=$env:CGO_ENABLED |
| 12 | try { |
| 13 | dotnet publish scripts/guest-os/guest-clipboard-windows/Cage.GuestClipboard.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -o $build |
| 14 | if ($LASTEXITCODE) {throw 'Could not publish the native Windows guest bridge.'} |
| 15 | Copy-Item -LiteralPath (Join-Path $build 'Cage.GuestClipboard.exe') -Destination $dest |
| 16 | $env:GOOS='windows'; $env:GOARCH='amd64'; $env:CGO_ENABLED='0' |
| 17 | go build -trimpath -o (Join-Path $dest 'cage-guest-files.exe') ./cmd/cage-guest-files |
| 18 | if ($LASTEXITCODE) {throw 'Could not build the Windows guest file helper.'} |
| 19 | go build -trimpath -o (Join-Path $dest 'cage-guest-boot.exe') ./cmd/cage-guest-boot |
| 20 | if ($LASTEXITCODE) {throw 'Could not build the Windows guest boot service.'} |
| 21 | go build -trimpath -o (Join-Path $dest 'Cage.HyperVManager.exe') ./cmd/cage-hyperv-manager |
| 22 | if ($LASTEXITCODE) {throw 'Could not build the scoped Windows host manager.'} |
| 23 | Push-Location (Join-Path $root 'tools/tailnet') |
| 24 | try { go build -trimpath -ldflags '-s -w' -o (Join-Path $dest 'cage-tailnet.exe') .; if ($LASTEXITCODE) { throw 'Could not build Cage Tailscale.' } } finally { Pop-Location } |
| 25 | Copy-Item -LiteralPath (Join-Path $root 'internal/cage/tailnet-client.mjs') -Destination $dest |
| 26 | foreach ($file in @('windows-browser.mjs','windows-browser-extensions.mjs','windows-phone-browser.mjs','windows-workbench-packages.json','install-windows-workbench-user-tools.ps1')) { |
| 27 | Copy-Item -LiteralPath (Join-Path $PSScriptRoot $file) -Destination $dest |
| 28 | } |
| 29 | foreach ($file in @('install-cli.ps1','cli-dependencies.json')) { |
| 30 | Copy-Item -LiteralPath (Join-Path $PSScriptRoot ('guest-clipboard-windows/'+$file)) -Destination $dest |
| 31 | } |
| 32 | $moduleDir=Join-Path $dest 'modules' |
| 33 | $null=New-Item -ItemType Directory -Force $moduleDir |
| 34 | foreach ($name in @('clipboard','uploads','downloads','cookies','extensions','vault','phone','phone-network')) { |
| 35 | Copy-Item -LiteralPath (Join-Path $root "internal/cage/browser-$name.mjs") -Destination $moduleDir |
| 36 | } |
| 37 | Copy-Item -LiteralPath (Join-Path $root 'internal/cage/split-extension') -Destination $dest -Recurse -Force |
| 38 | } finally { |
| 39 | $env:GOOS=$oldOS; $env:GOARCH=$oldArch; $env:CGO_ENABLED=$oldCGO |
| 40 | Pop-Location |
| 41 | if (Test-Path -LiteralPath $build) { Remove-Item -LiteralPath $build -Recurse -Force } |
| 42 | } |