From 1b8001b8b8757b6914e9b61a71ad1e092a5fa754 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Thu, 25 May 2023 17:34:05 +0300 Subject: [PATCH] fix(bundler/nsis): calculate accurate app size, closes #7056 (#7057) --- .changes/nsis-accurate-app-size.md | 5 +++++ .../src/bundle/windows/templates/installer.nsi | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 .changes/nsis-accurate-app-size.md diff --git a/.changes/nsis-accurate-app-size.md b/.changes/nsis-accurate-app-size.md new file mode 100644 index 000000000000..913e6602a63a --- /dev/null +++ b/.changes/nsis-accurate-app-size.md @@ -0,0 +1,5 @@ +--- +'tauri-bundler': 'patch:bug' +--- + +Fix incorrect estimated app size for NSIS bundler when installed to a non-empty directory. diff --git a/tooling/bundler/src/bundle/windows/templates/installer.nsi b/tooling/bundler/src/bundle/windows/templates/installer.nsi index dcb9948c4cd7..c8f5e2602c27 100644 --- a/tooling/bundler/src/bundle/windows/templates/installer.nsi +++ b/tooling/bundler/src/bundle/windows/templates/installer.nsi @@ -500,23 +500,31 @@ SectionEnd app_check_done: !macroend +Var AppSize Section Install SetOutPath $INSTDIR + StrCpy $AppSize 0 !insertmacro CheckIfAppIsRunning ; Copy main executable File "${MAINBINARYSRCPATH}" + ${GetSize} "$INSTDIR" "/M=${MAINBINARYNAME}.exe /S=0B" $0 $1 $2 + IntOp $AppSize $AppSize + $0 ; Copy resources {{#each resources}} CreateDirectory "$INSTDIR\\{{this.[0]}}" File /a "/oname={{this.[1]}}" "{{@key}}" + ${GetSize} "$INSTDIR" "/M={{this.[1]}} /S=0B" $0 $1 $2 + IntOp $AppSize $AppSize + $0 {{/each}} ; Copy external binaries {{#each binaries}} File /a "/oname={{this}}" "{{@key}}" + ${GetSize} "$INSTDIR" "/M={{this}} /S=0B" $0 $1 $2 + IntOp $AppSize $AppSize + $0 {{/each}} ; Create uninstaller @@ -540,9 +548,9 @@ Section Install WriteRegStr SHCTX "${UNINSTKEY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" WriteRegDWORD SHCTX "${UNINSTKEY}" "NoModify" "1" WriteRegDWORD SHCTX "${UNINSTKEY}" "NoRepair" "1" - ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 - IntFmt $0 "0x%08X" $0 - WriteRegDWORD SHCTX "${UNINSTKEY}" "EstimatedSize" "$0" + IntOp $AppSize $AppSize / 1000 + IntFmt $AppSize "0x%08X" $AppSize + WriteRegDWORD SHCTX "${UNINSTKEY}" "EstimatedSize" "$AppSize" ; Create start menu shortcut (GUI) !insertmacro MUI_STARTMENU_WRITE_BEGIN Application