$ErrorActionPreference = 'Stop'
Set-Location (Join-Path $PSScriptRoot '..')
$project = '.\src\Ikar.WinUI\Ikar.WinUI.csproj'
$target = '.\artifacts\winui-win64'

dotnet build $project -c Release -f net10.0-windows10.0.19041.0 -p:Platform=x64

if (Test-Path $target) {
    Remove-Item $target -Recurse -Force
}

New-Item -ItemType Directory -Path $target | Out-Null
Copy-Item '.\src\Ikar.WinUI\bin\x64\Release\net10.0-windows10.0.19041.0\win-x64\*' $target -Recurse -Force
Get-ChildItem $target -Recurse | Where-Object { $_.Name -like 'Massenger*' } | Remove-Item -Recurse -Force
Write-Host "Windows client prepared at $target\Ikar.WinUI.exe"
