build: package JD Windows binary with NSIS

This commit is contained in:
冰朔 2026-07-17 19:35:18 +08:00
parent b60b5783f8
commit 4f899da565
2 changed files with 92 additions and 4 deletions

View File

@ -42,13 +42,35 @@ rustup target add "$target"
command -v cargo-xwin >/dev/null || cargo install cargo-xwin --locked command -v cargo-xwin >/dev/null || cargo install cargo-xwin --locked
pnpm install --frozen-lockfile pnpm install --frozen-lockfile
pnpm tauri build --runner cargo-xwin --target "$target" --bundles nsis # Tauri's Linux CLI intentionally only exposes Linux bundle targets. Compile the
# Windows application with cargo-xwin, then hand the resulting payload to NSIS.
pnpm tauri build --runner cargo-xwin --target "$target" --no-bundle
bundle_dir="src-tauri/target/$target/release/bundle/nsis" release_dir="src-tauri/target/$target/release"
installer="$(find "$bundle_dir" -maxdepth 1 -type f -name '*-setup.exe' -print -quit)" app_exe="$release_dir/tolaria.exe"
[[ -n "$installer" ]] || { echo "No NSIS installer was produced." >&2; exit 1; } [[ -f "$app_exe" ]] || { echo "No Windows executable was produced: $app_exe" >&2; exit 1; }
bundle_dir="$release_dir/bundle/nsis"
stage_dir="$bundle_dir/stage"
installer="$bundle_dir/HoloLake-Era_${version}_x64-internal-setup.exe"
rm -rf "$stage_dir"
mkdir -p "$stage_dir/resources" "$bundle_dir"
cp "$app_exe" "$stage_dir/HoloLake Era.exe"
cp src-tauri/icons/icon.ico "$stage_dir/icon.ico"
cp -R src-tauri/resources/mcp-server "$stage_dir/resources/"
cp -R src-tauri/resources/agent-docs "$stage_dir/resources/"
cp -R src-tauri/resources/public-architecture "$stage_dir/resources/"
makensis \
-DAPP_VERSION="$version" \
-DSTAGE_DIR="$stage_dir" \
-DOUTPUT_FILE="$installer" \
scripts/windows-installer.nsi
[[ -f "$installer" ]] || { echo "No NSIS installer was produced." >&2; exit 1; }
[[ "$(basename "$installer")" == *"$version"* ]] || { echo "Installer filename does not contain version $version: $installer" >&2; exit 1; } [[ "$(basename "$installer")" == *"$version"* ]] || { echo "Installer filename does not contain version $version: $installer" >&2; exit 1; }
node scripts/verify-internal-package-content.mjs dist node scripts/verify-internal-package-content.mjs dist
node scripts/verify-internal-package-content.mjs "$stage_dir"
sha256sum "$installer" > "$installer.sha256" sha256sum "$installer" > "$installer.sha256"
echo "$installer" echo "$installer"

View File

@ -0,0 +1,66 @@
Unicode true
RequestExecutionLevel user
SetCompressor /SOLID lzma
!ifndef APP_VERSION
!error "APP_VERSION is required"
!endif
!ifndef STAGE_DIR
!error "STAGE_DIR is required"
!endif
!ifndef OUTPUT_FILE
!error "OUTPUT_FILE is required"
!endif
Name "HoloLake Era"
OutFile "${OUTPUT_FILE}"
InstallDir "$LOCALAPPDATA\Programs\HoloLake Era"
InstallDirRegKey HKCU "Software\Guanghu\HoloLake Era" "InstallDir"
Icon "${STAGE_DIR}/icon.ico"
UninstallIcon "${STAGE_DIR}/icon.ico"
VIProductVersion "0.1.5.0"
VIAddVersionKey "ProductName" "HoloLake Era"
VIAddVersionKey "ProductVersion" "${APP_VERSION}"
VIAddVersionKey "CompanyName" "Guanghu Language World"
VIAddVersionKey "FileDescription" "HoloLake Era internal installer"
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
Section "HoloLake Era" SEC_MAIN
SetOutPath "$INSTDIR"
File "${STAGE_DIR}/HoloLake Era.exe"
File "${STAGE_DIR}/icon.ico"
File /r "${STAGE_DIR}/resources"
WriteUninstaller "$INSTDIR\Uninstall.exe"
WriteRegStr HKCU "Software\Guanghu\HoloLake Era" "InstallDir" "$INSTDIR"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\HoloLakeEra" "DisplayName" "HoloLake Era"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\HoloLakeEra" "DisplayVersion" "${APP_VERSION}"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\HoloLakeEra" "DisplayIcon" "$INSTDIR\icon.ico"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\HoloLakeEra" "UninstallString" '"$INSTDIR\Uninstall.exe"'
CreateDirectory "$SMPROGRAMS\HoloLake Era"
CreateShortcut "$SMPROGRAMS\HoloLake Era\HoloLake Era.lnk" "$INSTDIR\HoloLake Era.exe" "" "$INSTDIR\icon.ico"
CreateShortcut "$DESKTOP\HoloLake Era.lnk" "$INSTDIR\HoloLake Era.exe" "" "$INSTDIR\icon.ico"
WriteRegStr HKCU "Software\Classes\tolaria" "" "URL:Tolaria Protocol"
WriteRegStr HKCU "Software\Classes\tolaria" "URL Protocol" ""
WriteRegStr HKCU "Software\Classes\tolaria\shell\open\command" "" '"$INSTDIR\HoloLake Era.exe" "%1"'
WriteRegStr HKCU "Software\Classes\guanghu" "" "URL:Guanghu Protocol"
WriteRegStr HKCU "Software\Classes\guanghu" "URL Protocol" ""
WriteRegStr HKCU "Software\Classes\guanghu\shell\open\command" "" '"$INSTDIR\HoloLake Era.exe" "%1"'
SectionEnd
Section "Uninstall"
Delete "$DESKTOP\HoloLake Era.lnk"
RMDir /r "$SMPROGRAMS\HoloLake Era"
DeleteRegKey HKCU "Software\Classes\tolaria"
DeleteRegKey HKCU "Software\Classes\guanghu"
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\HoloLakeEra"
DeleteRegKey HKCU "Software\Guanghu\HoloLake Era"
RMDir /r "$INSTDIR"
SectionEnd