# .NET SDK 8 for a Cleat box (inline [setup] commands).
#
# Drop this file in your project as ".cleat" and run `cleat run` (or
# `cleat start`). Cleat prints these exact commands and asks once before
# running them. They run a single time per container, as the "coder" user,
# in /workspace. A later `cleat rm` + `cleat run` re-provisions a fresh box.

[caps]
# Host git identity inside the box. Add more caps as your project needs them
# (ssh, gh, env, hooks, docker). See `cleat config --list`.
git

[setup]
# The base box is node:24-bookworm-slim (Debian 12 "bookworm"), amd64 or arm64.
# Microsoft's Debian apt feed only ships .NET 8 for amd64, so on arm64 (e.g.
# Apple Silicon) use the official arch-agnostic install script instead.
if [ "$(dpkg --print-architecture)" = "amd64" ]; then
  curl -fsSL https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -o /tmp/packages-microsoft-prod.deb
  sudo dpkg -i /tmp/packages-microsoft-prod.deb
  rm /tmp/packages-microsoft-prod.deb
  sudo apt-get update
  sudo apt-get install -y dotnet-sdk-8.0
else
  # dotnet-install.sh only unpacks the SDK, it never resolves dependencies, and
  # the slim base ships no ICU (verified). Without libicu the runtime FailFasts
  # at startup with exit 134 ("Couldn't find a valid ICU package"), so the
  # example's own `dotnet --info` would die. The amd64 branch above needs no
  # such line: apt pulls libicu in as a dotnet-sdk-8.0 dependency.
  sudo apt-get update
  sudo apt-get install -y libicu72
  curl -fsSL https://dot.net/v1/dotnet-install.sh -o /tmp/dotnet-install.sh
  bash /tmp/dotnet-install.sh --channel 8.0 --install-dir "$HOME/.dotnet"
  rm /tmp/dotnet-install.sh
  # Expose it by symlinking into ~/.local/bin rather than appending to
  # ~/.bashrc. The session already runs with ~/.local/bin first on PATH, and a
  # non-interactive payload never sources an rc file anyway, so the symlink is
  # both simpler and what actually takes effect. It is also re-runnable: `ln -sf`
  # replaces an existing link instead of appending a duplicate PATH line.
  ln -sf "$HOME/.dotnet/dotnet" "$HOME/.local/bin/dotnet"
  export PATH="$HOME/.dotnet:$PATH"
fi
dotnet --info
