$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
$project = Join-Path $root 'src\YandexParser.App\YandexParser.App.csproj'
$publish = Join-Path $root 'dist\SpectrumParser'
if (-not (Get-Command dotnet -ErrorAction SilentlyContinue)) {
throw 'dotnet SDK not found. Install .NET 10 SDK and run the script again.'
}
Remove-Item $publish -Recurse -Force -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path $publish -Force | Out-Null
dotnet restore $project
dotnet publish $project -c Release -r win-x64 --self-contained true -o $publish
# Install Playwright Chromium into the published application directory.
$pw = Join-Path $publish 'playwright.ps1'
if (Test-Path $pw) {
$env:PLAYWRIGHT_BROWSERS_PATH = '0'
& pwsh -NoProfile -ExecutionPolicy Bypass -File $pw install chromium
if ($LASTEXITCODE -ne 0) {
throw "Failed to install Chromium. Code: $LASTEXITCODE"
}
}
else {
Write-Warning 'playwright.ps1 not found. Chromium will be installed by the application on first launch.'
}
Write-Host ''
Write-Host 'Build completed.' -ForegroundColor Green
Write-Host $publish
Write-Host 'Launch:'
Write-Host (Join-Path $publish 'SpectrumParser.exe')