Skip to content

Commit

Permalink
fix(bundler/nsis): calculate accuratre app size, closes #7056
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed May 25, 2023
1 parent c4d6fb4 commit f55ace8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/nsis-accurate-app-size.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-bundler': 'patch:bug'
---

Fix incorrect estimated app size for NSIS bundler when installed to a non-empty directory.
14 changes: 11 additions & 3 deletions tooling/bundler/src/bundle/windows/templates/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f55ace8

Please sign in to comment.