Skip to content

Commit 1b8001b

Browse files
authored
fix(bundler/nsis): calculate accurate app size, closes #7056 (#7057)
1 parent c4d6fb4 commit 1b8001b

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

.changes/nsis-accurate-app-size.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri-bundler': 'patch:bug'
3+
---
4+
5+
Fix incorrect estimated app size for NSIS bundler when installed to a non-empty directory.

tooling/bundler/src/bundle/windows/templates/installer.nsi

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,23 +500,31 @@ SectionEnd
500500
app_check_done:
501501
!macroend
502502

503+
Var AppSize
503504
Section Install
504505
SetOutPath $INSTDIR
506+
StrCpy $AppSize 0
505507

506508
!insertmacro CheckIfAppIsRunning
507509

508510
; Copy main executable
509511
File "${MAINBINARYSRCPATH}"
512+
${GetSize} "$INSTDIR" "/M=${MAINBINARYNAME}.exe /S=0B" $0 $1 $2
513+
IntOp $AppSize $AppSize + $0
510514

511515
; Copy resources
512516
{{#each resources}}
513517
CreateDirectory "$INSTDIR\\{{this.[0]}}"
514518
File /a "/oname={{this.[1]}}" "{{@key}}"
519+
${GetSize} "$INSTDIR" "/M={{this.[1]}} /S=0B" $0 $1 $2
520+
IntOp $AppSize $AppSize + $0
515521
{{/each}}
516522

517523
; Copy external binaries
518524
{{#each binaries}}
519525
File /a "/oname={{this}}" "{{@key}}"
526+
${GetSize} "$INSTDIR" "/M={{this}} /S=0B" $0 $1 $2
527+
IntOp $AppSize $AppSize + $0
520528
{{/each}}
521529

522530
; Create uninstaller
@@ -540,9 +548,9 @@ Section Install
540548
WriteRegStr SHCTX "${UNINSTKEY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
541549
WriteRegDWORD SHCTX "${UNINSTKEY}" "NoModify" "1"
542550
WriteRegDWORD SHCTX "${UNINSTKEY}" "NoRepair" "1"
543-
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
544-
IntFmt $0 "0x%08X" $0
545-
WriteRegDWORD SHCTX "${UNINSTKEY}" "EstimatedSize" "$0"
551+
IntOp $AppSize $AppSize / 1000
552+
IntFmt $AppSize "0x%08X" $AppSize
553+
WriteRegDWORD SHCTX "${UNINSTKEY}" "EstimatedSize" "$AppSize"
546554

547555
; Create start menu shortcut (GUI)
548556
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application

0 commit comments

Comments
 (0)