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
Executable
+66
View File
@@ -0,0 +1,66 @@
#!/usr/bin/env bash
# Полный локальный гейт: формат, сборка, тесты.
#
# Обёртка вокруг `dotnet build` сама по себе бесполезна — ценность в том, что шаги идут в
# правильном порядке, падают быстро и возвращают ненулевой код возврата.
#
# ./build.sh формат, сборка и тесты в Release
# ./build.sh --fix переформатировать код, затем собрать и прогнать тесты
# ./build.sh -c Debug другая конфигурация
# ./build.sh --skip-tests только собрать
set -euo pipefail
cd "$(dirname "$0")"
SOLUTION=AvParser.slnx
CONFIGURATION=Release
FIX=0
SKIP_FORMAT=0
SKIP_TESTS=0
while [ $# -gt 0 ]; do
case "$1" in
-c|--configuration) CONFIGURATION="$2"; shift 2 ;;
--fix) FIX=1; shift ;;
--skip-format) SKIP_FORMAT=1; shift ;;
--skip-tests) SKIP_TESTS=1; shift ;;
-h|--help) sed -n '2,10p' "$0"; exit 0 ;;
*) echo "Неизвестный аргумент: $1" >&2; exit 2 ;;
esac
done
case "$CONFIGURATION" in
Debug|Release) ;;
*) echo "Конфигурация должна быть Debug или Release, получено: $CONFIGURATION" >&2; exit 2 ;;
esac
step() { printf '\n\033[36m==> %s\033[0m\n' "$1"; }
trap 'printf "\n\033[31mСБОЙ на шаге: %s\033[0m\n" "${CURRENT_STEP:-?}" >&2' ERR
CURRENT_STEP='Локальные инструменты'; step "$CURRENT_STEP"
dotnet tool restore
CURRENT_STEP='Восстановление пакетов'; step "$CURRENT_STEP"
dotnet restore "$SOLUTION"
if [ "$SKIP_FORMAT" -eq 0 ]; then
if [ "$FIX" -eq 1 ]; then
CURRENT_STEP='Форматирование (csharpier format)'; step "$CURRENT_STEP"
dotnet csharpier format .
else
# До сборки: несформатированный файл — самый дешёвый повод упасть.
CURRENT_STEP='Проверка форматирования (csharpier check)'; step "$CURRENT_STEP"
dotnet csharpier check .
fi
fi
CURRENT_STEP="Сборка ($CONFIGURATION)"; step "$CURRENT_STEP"
dotnet build "$SOLUTION" -c "$CONFIGURATION" --no-restore --nologo
if [ "$SKIP_TESTS" -eq 0 ]; then
CURRENT_STEP='Тесты'; step "$CURRENT_STEP"
dotnet test "$SOLUTION" -c "$CONFIGURATION" --no-build --nologo
fi
printf '\n\033[32mOK\033[0m\n'