#Requires -Version 5.1 <# LiveWall build script. Examples -------- .\build.ps1 # publish a framework-dependent build into .\prebuilt .\build.ps1 -Task run # build and start the app right away .\build.ps1 -Task selfcontained # single folder that runs on any Windows 11 PC (no .NET install needed) .\build.ps1 -Task sample # build the example plugin and install it into %APPDATA%\LiveWall\plugins .\build.ps1 -Task portable # zip the build with no installer at all (nothing for an AV to unpack) Requires the .NET 8 SDK: https://dotnet.microsoft.com/download/dotnet/8.0 #> param( [ValidateSet('build', 'run', 'publish', 'selfcontained', 'sample', 'portable')] [string]$Task = 'publish', [string]$Configuration = 'Release', [string]$Output = (Join-Path $PSScriptRoot 'prebuilt') ) $ErrorActionPreference = 'Stop' $project = Join-Path $PSScriptRoot 'LiveWall\LiveWall.csproj' if (-not (Get-Command dotnet -ErrorAction SilentlyContinue)) { Write-Host 'The .NET SDK was not found.' -ForegroundColor Red Write-Host 'Install the .NET 8 SDK (x64) from https://dotnet.microsoft.com/download/dotnet/8.0 and run this script again.' exit 1 } $sdk = (& dotnet --list-sdks) -join "`n" if ($sdk -notmatch '^([6-9]|1[0-9])\.') { Write-Host "A .NET 6.0 or newer SDK is required. Found:`n$sdk" -ForegroundColor Red exit 1 } Write-Host "Project : $project" Write-Host "Task : $Task ($Configuration)" Write-Host '' switch ($Task) { 'build' { dotnet build $project -c $Configuration if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } Write-Host "`nBuilt: $PSScriptRoot\LiveWall\bin\$Configuration\net8.0-windows\LiveWall.exe" } 'run' { dotnet run --project $project -c $Configuration } 'publish' { dotnet publish $project -c $Configuration -r win-x64 --self-contained false -o $Output if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } Write-Host "`nPublished to $Output" Write-Host 'Needs the .NET 8 Desktop Runtime on the target PC: https://dotnet.microsoft.com/download/dotnet/8.0/runtime' } 'selfcontained' { $Output = Join-Path $Output 'selfcontained' dotnet publish $project -c $Configuration -r win-x64 --self-contained true ` -p:PublishSingleFile=false -o $Output if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } Write-Host "`nPublished self-contained build to $Output (runs without installing .NET)" } 'portable' { # A plain zip is the least suspicious way to ship a small .NET app: no self-extracting stub, # no packed archive inside an executable, nothing for a heuristics engine to score. dotnet publish $project -c $Configuration -r win-x64 --self-contained false -o $Output if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } Get-ChildItem $Output -Filter *.pdb -Recurse | Remove-Item -Force -ErrorAction SilentlyContinue $zip = Join-Path $PSScriptRoot "LiveWall-$((Select-String -Path $project -Pattern '(.*)').Matches.Groups[1].Value)-portable.zip" if (Test-Path $zip) { Remove-Item $zip -Force } Compress-Archive -Path (Join-Path $Output '*') -DestinationPath $zip -CompressionLevel Optimal Write-Host "`nPortable build: $zip" Write-Host 'Unpack it anywhere and run LiveWall.exe. Needs the .NET 8 Desktop Runtime.' Write-Host ("SHA-256: " + (Get-FileHash $zip -Algorithm SHA256).Hash.ToLower()) } 'sample' { $plugin = Join-Path $PSScriptRoot 'samples\ClockOverlayPlugin\ClockOverlayPlugin.csproj' dotnet build $plugin -c $Configuration if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } $built = Join-Path $PSScriptRoot "samples\ClockOverlayPlugin\bin\$Configuration\net8.0-windows" $target = Join-Path $env:APPDATA 'LiveWall\plugins\com.example.clock' New-Item -ItemType Directory -Force -Path $target | Out-Null Copy-Item (Join-Path $built 'ClockOverlayPlugin.dll') $target -Force Copy-Item (Join-Path $built 'plugin.json') $target -Force Write-Host "`nExample plugin installed to $target" Write-Host 'Now: LiveWall > Plugins > Enable the plugin system > Rescan > Enable. It is third-party code, so read the warning.' } }