package.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env bash
  2. # ── 本地打包 · Local packaging ──
  3. # 构建 Release 并把 dll 按游戏根目录结构打成 zip
  4. # Build Release and zip the dll using the game-root layout
  5. # 用法 / Usage:scripts/package.sh
  6. # 前置 / Prerequisite:本机已安装 SPT 客户端(用 SPT_DIR 指定其根目录)
  7. # A local SPT client install (point SPT_DIR at its root)
  8. set -euo pipefail
  9. ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
  10. cd "$ROOT"
  11. export DOTNET_ROOT="${DOTNET_ROOT:-$HOME/.dotnet}"
  12. export PATH="$DOTNET_ROOT:$DOTNET_ROOT/tools:$PATH"
  13. # 从 csproj 读取版本号 / Read the version from the csproj
  14. VERSION="$(sed -n 's:.*<Version>\(.*\)</Version>.*:\1:p' src/PerformanceScope.Plugin/PerformanceScope.Plugin.csproj | head -1)"
  15. [ -n "$VERSION" ] || { echo "错误:未能从 csproj 读取 Version | Error: cannot read Version from csproj" >&2; exit 1; }
  16. OUT="artifacts"
  17. STAGE="$OUT/PerformanceScope"
  18. # 清理旧产物 / Clean previous output
  19. rm -rf "$OUT"
  20. mkdir -p "$STAGE/BepInEx/plugins/PerformanceScope"
  21. # 构建但不自动部署,改由 zip 分发 / Build without auto-deploy; the zip is the deliverable
  22. dotnet build src/PerformanceScope.Plugin/PerformanceScope.Plugin.csproj -c Release -p:DeployToGame=false
  23. cp "src/PerformanceScope.Plugin/bin/Release/PerformanceScope.dll" \
  24. "$STAGE/BepInEx/plugins/PerformanceScope/"
  25. (
  26. cd "$STAGE"
  27. zip -qr "../PerformanceScope-v${VERSION}.zip" .
  28. )
  29. rm -rf "$STAGE"
  30. echo "已生成 artifacts/PerformanceScope-v${VERSION}.zip | Generated artifacts/PerformanceScope-v${VERSION}.zip"