@@ -73,8 +73,26 @@ FunctionEnd
7373; --------------------------------
7474; Installer Sections
7575
76- Section " Base Installation" Base_Installation_Section
77- SectionIn RO # this section is required so user is unable to uncheck
76+ Function .onInstFailed
77+ # Ensure temporary files are cleaned up
78+ DetailPrint " Installation failed, cleaning up temporary files..."
79+
80+ ${If} ${FileExists} " $INSTDIR\cityenergyanalyst.tar.gz"
81+ Delete /REBOOTOK " $INSTDIR\cityenergyanalyst.tar.gz"
82+ ${EndIf}
83+
84+ ${If} ${FileExists} " $INSTDIR\dependencies"
85+ RMDir /r /REBOOTOK " $INSTDIR\dependencies"
86+ ${EndIf}
87+
88+ ${If} ${FileExists} " $INSTDIR\gui_setup.exe"
89+ Delete /REBOOTOK " $INSTDIR\gui_setup.exe"
90+ ${EndIf}
91+
92+
93+ FunctionEnd
94+
95+ Function BaseInstallationSection
7896 SetOutPath " $INSTDIR"
7997
8098 File " cityenergyanalyst.tar.gz"
@@ -100,22 +118,13 @@ Section "Base Installation" Base_Installation_Section
100118 ${EndIf}
101119 Delete " $INSTDIR\cityenergyanalyst.tar.gz"
102120
103- # create cea.config file in the %userprofile% directory by calling `cea --help` and set daysim paths
104- nsExec::ExecToLog ' "$INSTDIR\dependencies\micromamba.exe" run -r "$INSTDIR\dependencies\micromamba" -n cea cea --help '
121+ # Run cea --version to check if installation was successful
122+ nsExec::ExecToLog ' "$INSTDIR\dependencies\micromamba.exe" run -r "$INSTDIR\dependencies\micromamba" -n cea cea --version '
105123 Pop $0
106- DetailPrint ' "cea --help " returned $0'
124+ DetailPrint ' "cea --version " returned $0'
107125 ${If} " $0" != " 0"
108126 Abort " Installation failed - see Details"
109127 ${EndIf}
110- # WriteINIStr "$PROFILE\cea.config" radiation daysim-bin-directory "$INSTDIR\Dependencies\Daysim"
111-
112- # make sure qt.conf has the correct paths
113- # DetailPrint "Updating qt.conf..."
114- # ${StrRep} $0 "$INSTDIR" "\" "/" # $0 now contains the $INSTDIR with forward slashes instead of backward slashes
115- # WriteINIStr "$INSTDIR\Dependencies\Python\qt.conf" Paths Prefix "$0/Dependencies/Python/Library"
116- # WriteINIStr "$INSTDIR\Dependencies\Python\qt.conf" Paths Binaries "$0/Dependencies/Python/Library/bin"
117- # WriteINIStr "$INSTDIR\Dependencies\Python\qt.conf" Paths Libraries "$0/Dependencies/Python/Library/lib"
118- # WriteINIStr "$INSTDIR\Dependencies\Python\qt.conf" Paths Headers "$0/Dependencies/Python/Library/include/qt"
119128
120129 # make sure jupyter has access to the ipython kernel
121130 # nsExec::ExecToLog '"$INSTDIR\cea-env-run.bat" python -m ipykernel install --prefix $INSTDIR\Dependencies\Python'
@@ -142,11 +151,9 @@ Section "Base Installation" Base_Installation_Section
142151 # create a shortcut in the $INSTDIR for launching the CEA dashboard
143152 CreateShortcut " $INSTDIR\CEA Dashboard.lnk" " $INSTDIR\dashboard\CityEnergyAnalyst-GUI.exe" " " \
144153 " $INSTDIR\cea-icon.ico" 0 SW_SHOWNORMAL " " " Launch the CEA Dashboard"
154+ FunctionEnd
145155
146- SectionEnd
147-
148- Section " Create Start menu shortcuts" Create_Start_Menu_Shortcuts_Section
149-
156+ Function CreateStartMenuShortcutsSection
150157 # create shortcuts in the start menu for launching the CEA console
151158 CreateDirectory ' $SMPROGRAMS\${CEA_TITLE}'
152159 CreateShortCut ' $SMPROGRAMS\${CEA_TITLE}\CEA Console.lnk' " $WINDIR\System32\cmd.exe" ' /K "$INSTDIR\dependencies\cea-env.bat"' \
@@ -158,24 +165,18 @@ Section "Create Start menu shortcuts" Create_Start_Menu_Shortcuts_Section
158165 CreateShortcut " $SMPROGRAMS\${CEA_TITLE}\Uninstall CityEnergy Analyst.lnk" \
159166 " $INSTDIR\Uninstall_CityEnergyAnalyst_${VER}.exe" " " \
160167 " $INSTDIR\Uninstall_CityEnergyAnalyst_${VER}.exe" 0 SW_SHOWNORMAL " " " Uninstall the City Energy Analyst"
168+ FunctionEnd
161169
162- SectionEnd
163-
164- Section /o " Create Desktop shortcuts" Create_Desktop_Shortcuts_Section
165-
170+ Function CreateDesktopShortcutsSection
166171 # create shortcuts on the Desktop for launching the CEA console
167172 CreateShortCut ' $DESKTOP\CEA Console.lnk' " $WINDIR\System32\cmd.exe" ' /K "$INSTDIR\dependencies\cea-env.bat"' \
168173 " $INSTDIR\cea-icon.ico" 0 SW_SHOWNORMAL " " " Launch the CEA Console"
169174
170175 CreateShortcut " $DESKTOP\CEA Dashboard.lnk" " $INSTDIR\dashboard\CityEnergyAnalyst-GUI.exe" " " \
171176 " $INSTDIR\cea-icon.ico" 0 SW_SHOWNORMAL " " " Launch the CEA Dashboard"
177+ FunctionEnd
172178
173- SectionEnd
174-
175- ; Uninstaller Section
176-
177- Section " Uninstall"
178-
179+ Function un.UninstallSection
179180 ; Delete the shortcuts
180181 Delete /REBOOTOK " $SMPROGRAMS\${CEA_TITLE}\CEA Console.lnk"
181182 Delete /REBOOTOK " $SMPROGRAMS\${CEA_TITLE}\CEA Dashboard.lnk"
@@ -198,10 +199,21 @@ Section "Uninstall"
198199 RMDir /R /REBOOTOK " $INSTDIR\dependencies"
199200
200201 Delete /REBOOTOK " $INSTDIR\Uninstall_CityEnergyAnalyst_${VER}.exe"
202+ FunctionEnd
201203
202- ; Change current working directory so that it can be deleted
203- ; Will only be deleted if the directory is empty
204- SetOutPath $TEMP
205- RMDir /REBOOTOK " $INSTDIR"
204+ Section " Base Installation" Base_Installation_Section
205+ SectionIn RO # this section is required so user is unable to uncheck
206+ Call BaseInstallationSection
207+ SectionEnd
208+
209+ Section " Create Start menu shortcuts" Create_Start_Menu_Shortcuts_Section
210+ Call CreateStartMenuShortcutsSection
211+ SectionEnd
206212
213+ Section /o " Create Desktop shortcuts" Create_Desktop_Shortcuts_Section
214+ Call CreateDesktopShortcutsSection
215+ SectionEnd
216+
217+ Section " Uninstall"
218+ Call un.UninstallSection
207219SectionEnd
0 commit comments