<# Builds the Windows client and dedicated server (Release, x64) and assembles ready to run folders: dist\MinecraftPE-win64\ client (MinecraftPE.exe, data\, lua\, mods\) dist\MinecraftPE-server-win64\ server (MinecraftPE-server.exe, lua\, mods\) Requirements: Visual Studio 2022 (C++ workload) and CMake. The first run downloads the dependencies (zlib, libpng, glfw, OpenAL Soft, LuaJIT, stb) with git. .\package-windows.ps1 full build + package .\package-windows.ps1 -NoBuild only (re)assemble dist from an existing build .\package-windows.ps1 -Jobs 2 fewer parallel compiler jobs (low memory machines) #> param( [switch]$NoBuild, [int]$Jobs = 4 ) $ErrorActionPreference = 'Stop' $root = $PSScriptRoot $build = Join-Path $root 'build' $dist = Join-Path $root 'dist' # The dependencies are cloned with git; drives that do not record file ownership make git refuse # that ("dubious ownership"). Tell git to trust directories for this process only. $env:GIT_CONFIG_COUNT = '1' $env:GIT_CONFIG_KEY_0 = 'safe.directory' $env:GIT_CONFIG_VALUE_0 = '*' if (-not $NoBuild) { cmake -S $root -B $build -G 'Visual Studio 17 2022' -A x64 if ($LASTEXITCODE -ne 0) { throw 'CMake configure failed' } # OpenAL Soft needs a lot of memory per compiler process, so the compiler parallelism is limited cmake --build $build --config Release --parallel $Jobs -- /p:CL_MPCount=2 if ($LASTEXITCODE -ne 0) { throw 'Build failed' } } $rel = Join-Path $build 'Release' foreach ($f in 'MinecraftPE.exe', 'MinecraftPE-server.exe') { if (-not (Test-Path (Join-Path $rel $f))) { throw "$f not found in $rel" } } if (Test-Path $dist) { Remove-Item $dist -Recurse -Force } # ---- client $client = Join-Path $dist 'MinecraftPE-win64' New-Item -ItemType Directory -Force $client | Out-Null Copy-Item (Join-Path $rel 'MinecraftPE.exe') $client Get-ChildItem $rel -Filter *.dll | Copy-Item -Destination $client Copy-Item (Join-Path $root 'data') $client -Recurse Copy-Item (Join-Path $root 'lua') $client -Recurse Copy-Item (Join-Path $root 'mods') $client -Recurse # ---- server $server = Join-Path $dist 'MinecraftPE-server-win64' New-Item -ItemType Directory -Force $server | Out-Null Copy-Item (Join-Path $rel 'MinecraftPE-server.exe') $server Copy-Item (Join-Path $root 'lua') $server -Recurse Copy-Item (Join-Path $root 'mods') $server -Recurse @" port=19132 level-dir=level level-cachepath=. level-externalpath=. gamemode=creative level-name=level view-distance=10 "@ | Set-Content (Join-Path $server 'server.properties') -Encoding ascii Set-Content (Join-Path $server 'start-server.bat') "@echo off`r`nMinecraftPE-server.exe`r`npause" -Encoding ascii Write-Host '' Write-Host 'Done:' Write-Host " $client" Write-Host " $server"