Add build and run scripts; drop the broken Avalonia.Diagnostics reference

A wrapper around `dotnet build` earns nothing, so build.ps1/build.sh are the
full local gate instead — tool restore, package restore, format check, build,
test — in the order that fails cheapest first, with a non-zero exit on failure.
run.ps1/run.sh default to Debug and pass extra arguments through to the app.
Both flavours ship because the Desktop head targets Windows, Linux and macOS.

Writing them immediately paid for itself: the very first run failed restore on
Avalonia.Diagnostics 12.1.1, which does not exist — the package stops at 11.3.x
because Avalonia 12 moved the inspector into a separate tool with its own
installation. The reference had survived because it sat behind
Condition="'$(Configuration)' == 'Debug'", and `dotnet restore` evaluates with
the default configuration while every build so far had passed -c Release. So
`dotnet build -c Release` worked and a bare `dotnet restore` did not.

Reference removed rather than replaced: AvaloniaUI.DiagnosticsSupport pulls in a
separately installed tool, which is not a dependency to add to a skeleton without
asking. README and CLAUDE.md no longer promise F12, and both traps are written
down where the next person will hit them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Leonid Pershin
2026-08-13 16:32:16 +03:00
co-authored by Claude Opus 5
parent 3db9d4dfc6
commit aeafe0af36
9 changed files with 306 additions and 16 deletions
+97
View File
@@ -0,0 +1,97 @@
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Полный локальный гейт: формат, сборка, тесты.
.DESCRIPTION
То, что имеет смысл прогнать перед коммитом. Обёртка вокруг `dotnet build` сама по себе
бесполезна — ценность здесь в том, что шаги идут в правильном порядке, падают быстро и
возвращают ненулевой код возврата.
.PARAMETER Configuration
Debug или Release. По умолчанию Release — гейт должен проверять то, что уедет.
.PARAMETER Fix
Переформатировать код вместо проверки. Без этого флага несформатированный код валит сборку.
.PARAMETER SkipFormat
Пропустить проверку форматирования.
.PARAMETER SkipTests
Только собрать, не запускать тесты.
.EXAMPLE
./build.ps1
Формат, сборка и тесты в Release.
.EXAMPLE
./build.ps1 -Fix
Переформатировать код, затем собрать и прогнать тесты.
#>
[CmdletBinding()]
param(
[ValidateSet('Debug', 'Release')]
[string] $Configuration = 'Release',
[switch] $Fix,
[switch] $SkipFormat,
[switch] $SkipTests
)
$ErrorActionPreference = 'Stop'
Set-Location $PSScriptRoot
$solution = 'AvParser.slnx'
$started = Get-Date
function Invoke-Step {
param(
[Parameter(Mandatory)] [string] $Name,
[Parameter(Mandatory)] [scriptblock] $Action
)
Write-Host ''
Write-Host "==> $Name" -ForegroundColor Cyan
& $Action
# Native executables do not raise terminating errors, so the exit code is the only signal.
if ($LASTEXITCODE -ne 0) {
throw "$Name — код возврата $LASTEXITCODE"
}
}
try {
Invoke-Step 'Локальные инструменты' { dotnet tool restore }
Invoke-Step 'Восстановление пакетов' { dotnet restore $solution }
if (-not $SkipFormat) {
if ($Fix) {
Invoke-Step 'Форматирование (csharpier format)' { dotnet csharpier format . }
}
else {
# Before the build: an unformatted file is the cheapest possible failure.
Invoke-Step 'Проверка форматирования (csharpier check)' { dotnet csharpier check . }
}
}
Invoke-Step "Сборка ($Configuration)" {
dotnet build $solution -c $Configuration --no-restore --nologo
}
if (-not $SkipTests) {
Invoke-Step 'Тесты' {
dotnet test $solution -c $Configuration --no-build --nologo
}
}
$elapsed = (Get-Date) - $started
Write-Host ''
Write-Host ("OK — {0:mm\:ss}" -f $elapsed) -ForegroundColor Green
}
catch {
Write-Host ''
Write-Host "СБОЙ: $_" -ForegroundColor Red
exit 1
}