1 ; =================================================================
2 ; mono.nsi - This NSIS script creates Mono Setup wizard for Windows
4 ; Requires NSIS 2.0 (Nullsoft Scriptable Install System)
5 ; From http://nsis.sourceforge.net/site/index.php
6 ; =================================================================
8 ; (C) Copyright 2003 by Johannes Roith
9 ; (C) Copyright 2003, 2004 by Daniel Morgan
12 ; Johannes Roith <johannes@jroith.de>
13 ; Daniel Morgan <danielmorgan@verizon.net>
14 ; Urs C Muff <umuff@quark.com>
15 ; Gonzalo Paniagua Javier <gonzalo@ximian.com>
17 ; This .nsi includes code from the NSIS Archives:
18 ; function StrReplace and VersionCheck
20 ; HendriAdriaens@hotmail.com
22 ; =====================================================
24 ; This script can build a binary setup wizard of mono.
25 ; It is released under the GNU GPL.
28 !include "Sections.nsh"
31 ; =====================================================
32 ; SET MILESTONE & SOURCE DIR
33 ; =====================================================
36 ;!define MILESTONE 0.91.99
38 ;!define SOURCE_INSTALL_DIR ..\install\*.*
40 ; Used to install mcs.exe
41 !define PROFILE_VERSION
1.0
43 ; =====================================================
45 ; =====================================================
49 ; This adds a Mono-specific Image on the left
50 ; You can choose between the light or dark one.
52 ; If you wish no mono-specifi logo, please outcomment
57 ; !define MUI_SPECIALBITMAP "mono-win32-setup-dark.bmp"
58 !define MUI_SPECIALBITMAP
"mono-win32-setup-light.bmp"
60 ; =====================================================
62 ; =====================================================
64 ; 1. Build mono to a clean directory prefix.
66 ; 2. In your install directory, delete the *.a files.
67 ; Most people won't need them and it saves ~ 4 MB.
69 ; 3. Type "make win32setup"
71 ; 4. The output file is mono-[MILESTONE]-win32-[BUILDNUM].exe
74 ; =====================================================
75 ; MONO & REGISTRY / DETECTING MONO
76 ; =====================================================
79 ; This setup creates several Registry Keys:
81 ; HKEY_LOCAL_MACHINE SOFTWARE\Mono DefaultCLR
82 ; HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} SdkInstallRoot
83 ; HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} FrameworkAssemblyDirectory
84 ; HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} MonoConfigDir
86 ; =====================================================
88 ; To get the current Mono Install Directory:
91 ; 2. Get HKEY_LOCAL_MACHINE SOFTWARE\Mono\$THE_DEFAULT_CLR_VALUE SdkInstallRoot
93 ; =====================================================
95 ; To get the current Mono assembly Directory:
98 ; 2. Get HKEY_LOCAL_MACHINE SOFTWARE\Mono\$THE_DEFAULT_CLR_VALUE FrameworkAssemblyDirectory
100 ; =====================================================
102 ; =====================================================
105 ; =====================================================
106 ; GENERAL SETTING - NEED NOT TO BE CHANGED
107 ; =====================================================
110 !define TARGET_INSTALL_DIR
"$PROGRAMFILES\Mono-${MILESTONE}"
111 !define OUTFILE mono
-${MILESTONE}-win32
-${BUILDNUM}.exe
114 Caption "Mono ${MILESTONE} Build ${BUILDNUM} Setup"
120 SetDatablockOptimize on
122 BGGradient 000000 800000 FFFFFF
123 InstallColors FF8080
000030
125 AutoCloseWindow false
127 ; =====================================================
129 ; =====================================================
131 #!define MUI_WELCOMEPAGE
132 #!define MUI_DIRECTORYPAGE
133 #!define MUI_DIRECTORYSELECTIONPAGE
135 !define MUI_WELCOMEPAGE_TEXT
"This wizard will guide you through the installation of Mono for Windows.\r\n\r\n\r\n$_CLICK"
137 !insertmacro MUI_PAGE_WELCOME
138 !insertmacro MUI_PAGE_DIRECTORY
139 !insertmacro MUI_PAGE_INSTFILES
141 !define MUI_FINISHPAGE_LINK
"Visit Mono's website for the latest news"
142 !define MUI_FINISHPAGE_LINK_LOCATION
"http://www.go-mono.com/"
144 !define MUI_FINISHPAGE_NOREBOOTSUPPORT
146 !insertmacro MUI_PAGE_FINISH
148 !insertmacro MUI_UNPAGE_CONFIRM
149 !insertmacro MUI_UNPAGE_INSTFILES
151 !insertmacro MUI_LANGUAGE
"ENGLISH"
153 AutoCloseWindow false
157 InstallDir "${TARGET_INSTALL_DIR}"
159 ;========================
161 ;========================
165 MessageBox MB_YESNO "Are you sure you want to uninstall Mono from your system?" IDNO NoUnInstall
167 Delete "$INSTDIR\Uninst.exe" ; delete Uninstaller
168 DeleteRegKey HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mono
-${MILESTONE} ; Remove Entry in Software List
170 MessageBox MB_YESNO "Mono was installed into $INSTDIR. Should this directory be removed completly?" IDNO GoNext1
174 DeleteRegKey HKLM SOFTWARE\Mono\
${MILESTONE}
176 ; If the Default-Key is the current Milestone, we just remove the wrappers
178 ReadRegStr $0 HKEY_LOCAL_MACHINE SOFTWARE\Mono DefaultCLR
179 StrCmp $0 ${MILESTONE} DeleteWrappers
181 MessageBox MB_YESNO "Mono ${MILESTONE} Build ${BUILDNUM} has been removed, but the default installation of Mono differs form this version. Should the wrappers and the Mono registry key be still be removed? This could disable other Mono installations." IDNO GoNext2
195 ; Warn people if a newer Mono is already installed
197 ReadRegStr $0 HKEY_LOCAL_MACHINE SOFTWARE\Mono DefaultCLR
202 StrCmp $0 0 NoAskInstall
203 StrCmp $0 2 NoAskInstall
204 MessageBox MB_YESNO "A newer Mono version is already installed. Still continue?" IDNO NoInstall
208 DetailPrint "Installing Mono Files..."
211 File /r
${SOURCE_INSTALL_DIR}
213 WriteUninstaller Uninst
.exe
215 WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono\
${MILESTONE} SdkInstallRoot
$INSTDIR
216 WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono\
${MILESTONE} FrameworkAssemblyDirectory
$INSTDIR\lib
217 WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono\
${MILESTONE} MonoConfigDir
$INSTDIR\etc
218 ;WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} GtkSharpLibPath $INSTDIR\lib
219 WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono DefaultCLR
${MILESTONE}
221 ; Mono Uninstall Entry in Windows Software List in the Control panel
222 WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mono
-${MILESTONE} DisplayName
"Mono ${MILESTONE}"
223 WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mono
-${MILESTONE} UninstallString
$INSTDIR\uninst
.exe
225 ;original string is like C:\mono-0.20\install
228 Push "\" ;search for this string
229 Push "/" ;replace with this string
231 ;resulting string which is like C:/mono-0.20/install
235 ; These wrappers are copied to the windows directory.
238 ;========================
239 ; Write the path file
240 ;========================
258 Call windowsBatProfile
261 Call windowsBatProfile
265 Call createWindowsBatFiles
268 ; ============= glib-2.0.pc ===============
269 FileOpen $0 "$INSTDIR\lib\pkgconfig\glib-2.0.pc" "w"
270 FileWrite $0 "prefix=$6$\r$\n"
271 FileWrite $0 "exec_prefix=$${prefix}$\r$\n"
272 FileWrite $0 "libdir=$${exec_prefix}/lib$\r$\n"
273 FileWrite $0 "includedir=$${prefix}/include$\r$\n"
274 FileWrite $0 "$\r$\n"
275 FileWrite $0 "glib_genmarshal=glib-genmarshal$\r$\n"
276 FileWrite $0 "gobject_query=gobject-query$\r$\n"
277 FileWrite $0 "glib_mkenums=glib-mkenums$\r$\n"
278 FileWrite $0 "$\r$\n"
279 FileWrite $0 "Name: GLib$\r$\n"
280 FileWrite $0 "Description: C Utility Library$\r$\n"
281 FileWrite $0 "Version: 2.0.4$\r$\n"
282 FileWrite $0 "Libs: -L$${libdir} -lglib-2.0 -lintl -liconv $\r$\n"
283 FileWrite $0 "Cflags: -I$${includedir}/glib-2.0 -I$${libdir}/glib-2.0/include $\r$\n"
286 ; ============= gmodule-2.0.pc ===============
287 FileOpen $0 "$INSTDIR\lib\pkgconfig\gmodule-2.0.pc" "w"
288 FileWrite $0 "prefix=$6$\r$\n"
289 FileWrite $0 "exec_prefix=$${prefix}$\r$\n"
290 FileWrite $0 "libdir=$${exec_prefix}/lib$\r$\n"
291 FileWrite $0 "includedir=$${prefix}/include$\r$\n"
292 FileWrite $0 "$\r$\n"
293 FileWrite $0 "gmodule_supported=true$\r$\n"
294 FileWrite $0 "$\r$\n"
295 FileWrite $0 "Name: GModule$\r$\n"
296 FileWrite $0 "Description: Dynamic module loader for GLib$\r$\n"
297 FileWrite $0 "Requires: glib-2.0$\r$\n"
298 FileWrite $0 "Version: 2.0.4$\r$\n"
299 FileWrite $0 "Libs: -L$${libdir} -lgmodule-2.0 $\r$\n"
300 FileWrite $0 "Cflags:$\r$\n"
303 ; ============= gobject-2.0.pc ===============
304 FileOpen $0 "$INSTDIR\lib\pkgconfig\gobject-2.0.pc" "w"
305 FileWrite $0 "prefix=$6$\r$\n"
306 FileWrite $0 "exec_prefix=$${prefix}$\r$\n"
307 FileWrite $0 "libdir=$${exec_prefix}/lib$\r$\n"
308 FileWrite $0 "includedir=$${prefix}/include$\r$\n"
309 FileWrite $0 "$\r$\n"
310 FileWrite $0 "Name: GObject$\r$\n"
311 FileWrite $0 "Description: GLib Type, Object, Parameter and Signal Library$\r$\n"
312 FileWrite $0 "Requires: glib-2.0$\r$\n"
313 FileWrite $0 "Version: 2.0.4$\r$\n"
314 FileWrite $0 "Libs: -L$${libdir} -lgobject-2.0$\r$\n"
315 FileWrite $0 "Cflags:$\r$\n"
318 ; ============= gthread-2.0.pc ===============
319 FileOpen $0 "$INSTDIR\lib\pkgconfig\gthread-2.0.pc" "w"
320 FileWrite $0 "prefix=$6$\r$\n"
321 FileWrite $0 "exec_prefix=$${prefix}$\r$\n"
322 FileWrite $0 "libdir=$${exec_prefix}/lib$\r$\n"
323 FileWrite $0 "includedir=$${prefix}/include$\r$\n"
324 FileWrite $0 "$\r$\n"
325 FileWrite $0 "Name: GThread$\r$\n"
326 FileWrite $0 "Description: Thread support for GLib$\r$\n"
327 FileWrite $0 "Requires: glib-2.0$\r$\n"
328 FileWrite $0 "Version: 2.0.4$\r$\n"
329 FileWrite $0 "Libs: -L$${libdir} -lgthread-2.0 $\r$\n"
330 FileWrite $0 "Cflags: -D_REENTRANT$\r$\n"
333 ; ============= libintl.pc ===============
334 FileOpen $0 "$INSTDIR\lib\pkgconfig\libintl.pc" "w"
335 FileWrite $0 "prefix=$6$\r$\n"
336 FileWrite $0 "exec_prefix=$${prefix}$\r$\n"
337 FileWrite $0 "libdir=$${exec_prefix}/lib$\r$\n"
338 FileWrite $0 "includedir=$${prefix}/include$\r$\n"
339 FileWrite $0 "$\r$\n"
340 FileWrite $0 "Name: libintl$\r$\n"
341 FileWrite $0 "Description: The intl library from GNU gettext$\r$\n"
342 FileWrite $0 "Version: 0.10.40-tml$\r$\n"
343 FileWrite $0 "Libs: -L$${libdir} -lintl$\r$\n"
344 FileWrite $0 "Cflags: -I$${includedir}$\r$\n"
347 Call CreateSetMonoPath
350 MessageBox MB_ICONINFORMATION
"Don't forget to prepend $INSTDIR\bin to your PATH when using Mono ${MILESTONE} Build ${BUILDNUM}.$\r$\nYou can use $INSTDIR\bin\setmonopath.bat to do it."
355 Function PushBatFiles
380 Function createWindowsBatFiles
383 StrCmp "$0" "" endcreateloop
390 Function CreateCreategac
392 FileOpen $1 "$INSTDIR\creategac.bat" "w"
393 FileWrite $1 "@echo off$\r$\n"
394 FileWrite $1 "echo Mono version ${MILESTONE} Build ${BUILDNUM}$\r$\n"
395 FileWrite $1 "echo Running gacutil to install system assemblies into the GAC$\r$\n"
396 FileWrite $1 "SETLOCAL$\r$\n"
397 FileWrite $1 "PATH=$INSTDIR\bin;%PATH%$\r$\n"
398 FileWrite $1 '"$INSTDIR\bin\gacutil.bat" -il "$INSTDIR\lib\mono\${PROFILE_VERSION}\full-path-assemblies.lst"$\r$\n'
399 FileWrite $1 "ENDLOCAL$\r$\n"
404 Function CreateSetMonoPath
406 FileOpen $1 "$INSTDIR\bin\setmonopath.bat" "w"
407 FileWrite $1 "@echo off$\r$\n"
408 FileWrite $1 "echo Mono version ${MILESTONE} Build ${BUILDNUM}$\r$\n"
409 FileWrite $1 "echo Prepending '$INSTDIR\bin' to PATH$\r$\n"
410 FileWrite $1 "PATH=$INSTDIR\bin;%PATH%$\r$\n"
419 FileOpen $1 "$INSTDIR\lib\mono\${PROFILE_VERSION}\assemblies.lst" "r"
420 FileOpen $2 "$INSTDIR\lib\mono\${PROFILE_VERSION}\full-path-assemblies.lst" "w"
423 StrCmp "$3" "" giveup
424 FileWrite $2 "$INSTDIR\lib\mono\${PROFILE_VERSION}\$3"
429 ExecWait '"$INSTDIR\bin\gacutil.bat" -il "$INSTDIR\lib\mono\${PROFILE_VERSION}\full-path-assemblies.lst"'
430 IfErrors errrun noerr
432 MessageBox MB_ICONEXCLAMATION 'Error running gacutil!$\r$\nRun "$INSTDIR\creategac.bat" after finishing setup program.'
434 ;Delete "$INSTDIR\lib\mono\${PROFILE_VERSION}\assemblies.lst"
435 ;Delete "$INSTDIR\lib\mono\${PROFILE_VERSION}\full-path-assemblies.lst"
442 Function windowsBatCore
443 Exch $1 ;core exe name
445 FileOpen $0 "$INSTDIR\bin\$1.bat" "w"
446 FileWrite $0 "@ECHO OFF$\r$\n"
447 FileWrite $0 "SET MONOARGS=$\r$\n"
448 FileWrite $0 ":loop$\r$\n"
449 FileWrite $0 "IF x%1 == x goto :done$\r$\n"
450 FileWrite $0 'SET MONOARGS=%MONOARGS% %1$\r$\n'
451 FileWrite $0 "SHIFT$\r$\n"
452 FileWrite $0 "GOTO loop$\r$\n"
453 FileWrite $0 ":done$\r$\n"
454 FileWrite $0 "SETLOCAL$\r$\n"
455 FileWrite $0 'SET PATH=$INSTDIR\bin;%PATH%$\r$\n'
456 FileWrite $0 'SET MONO_PATH=$INSTDIR\lib$\r$\n'
457 FileWrite $0 'SET MONO_CFG_DIR=$INSTDIR\etc$\r$\n'
458 FileWrite $0 '"$INSTDIR\lib\$1.exe" %MONOARGS%$\r$\n'
459 FileWrite $0 "ENDLOCAL$\r$\n"
462 FileOpen $0 "$INSTDIR\bin\$1" "w"
463 FileWrite $0 "#!/bin/sh$\n"
464 FileWrite $0 'IDIRUNIX="`cygpath -u '
465 FileWrite $0 "'$INSTDIR'`"
467 FileWrite $0 'PATH="$${IDIRUNIX}/bin:$$PATH"$\n'
468 FileWrite $0 "MONO_PATH='$INSTDIR\lib'$\n"
469 FileWrite $0 "MONO_CFG_DIR='$INSTDIR\etc'$\n"
470 FileWrite $0 "export PATH MONO_PATH MONO_CFG_DIR$\n"
471 FileWrite $0 'exec "$6/lib/$1.exe" "$$@"$\n'
480 FileOpen $0 "$INSTDIR\bin\$1.bat" "w"
481 FileWrite $0 "@ECHO OFF$\r$\n"
482 FileWrite $0 "SET MONOARGS=$\r$\n"
483 FileWrite $0 ":loop$\r$\n"
484 FileWrite $0 "IF x%1 == x GOTO :done$\r$\n"
485 FileWrite $0 'SET MONOARGS=%MONOARGS% %1$\r$\n'
486 FileWrite $0 "SHIFT$\r$\n"
487 FileWrite $0 "GOTO loop$\r$\n"
488 FileWrite $0 ":done$\r$\n"
489 FileWrite $0 "SETLOCAL$\r$\n"
490 FileWrite $0 'SET PATH=$INSTDIR\bin;%PATH%$\r$\n'
491 FileWrite $0 'SET MONO_PATH=$INSTDIR\lib$\r$\n'
492 FileWrite $0 'SET MONO_CFG_DIR=$INSTDIR\etc$\r$\n'
493 FileWrite $0 '"$INSTDIR\lib\mono.exe" "$INSTDIR\lib\$1.exe" %MONOARGS%$\r$\n'
494 FileWrite $0 "ENDLOCAL$\r$\n"
497 FileOpen $0 "$INSTDIR\bin\$1" "w"
498 FileWrite $0 "#!/bin/sh$\n"
499 FileWrite $0 'IDIRUNIX="`cygpath -u '
500 FileWrite $0 "'$INSTDIR'`"
502 FileWrite $0 'PATH="$${IDIRUNIX}/bin:$$PATH"$\n'
503 FileWrite $0 "MONO_PATH='$INSTDIR\lib'$\n"
504 FileWrite $0 "MONO_CFG_DIR='$INSTDIR\etc'$\n"
505 FileWrite $0 "export PATH MONO_PATH MONO_CFG_DIR$\n"
506 FileWrite $0 'exec "$6/lib/mono.exe" "$6/lib/$1.exe" "$$@"$\n'
512 Function windowsBatProfile
515 FileOpen $0 "$INSTDIR\bin\$1.bat" "w"
516 FileWrite $0 "@ECHO OFF$\r$\n"
517 FileWrite $0 "SET MONOARGS=$\r$\n"
518 FileWrite $0 ":loop$\r$\n"
519 FileWrite $0 "IF x%1 == x GOTO :done$\r$\n"
520 FileWrite $0 'SET MONOARGS=%MONOARGS% %1$\r$\n'
521 FileWrite $0 "SHIFT$\r$\n"
522 FileWrite $0 "GOTO loop$\r$\n"
523 FileWrite $0 ":done$\r$\n"
524 FileWrite $0 "SETLOCAL$\r$\n"
525 FileWrite $0 'SET PATH=$INSTDIR\bin;%PATH%$\r$\n'
526 FileWrite $0 'SET MONO_PATH=$INSTDIR\lib$\r$\n'
527 FileWrite $0 'SET MONO_CFG_DIR=$INSTDIR\etc$\r$\n'
528 FileWrite $0 '"$INSTDIR\lib\mono.exe" "$INSTDIR\lib\mono\${PROFILE_VERSION}\$1.exe" %MONOARGS%$\r$\n'
529 FileWrite $0 "ENDLOCAL$\r$\n"
532 FileOpen $0 "$INSTDIR\bin\$1" "w"
533 FileWrite $0 "#!/bin/sh$\n"
534 FileWrite $0 'IDIRUNIX="`cygpath -u '
535 FileWrite $0 "'$INSTDIR'`"
537 FileWrite $0 'PATH="$$IDIRUNIX/bin:$$PATH"$\n'
538 FileWrite $0 "MONO_PATH='$INSTDIR\lib'$\n"
539 FileWrite $0 "MONO_CFG_DIR='$INSTDIR\etc'$\n"
540 FileWrite $0 "export PATH MONO_PATH MONO_CFG_DIR$\n"
541 FileWrite $0 'exec "$6/lib/mono.exe" "$6/lib/mono/${PROFILE_VERSION}/$1.exe" "$$@"$\n'
547 ; function StrReplace
549 ; HendriAdriaens@hotmail.com
550 ; found in the NSIS Archives
552 Exch $0 ;this will replace wrong characters
554 Exch $1 ;needs to be replaced
557 Exch $2 ;the orginal string
559 Push $4 ;temp character
561 Push $6 ;length of string that need to be replaced
562 Push $7 ;length of string that will replace
573 StrCmp $4 "" ExitLoop
598 Function VersionCheck
599 Exch $0 ;second versionnumber
601 Exch $1 ;first versionnumber
602 Push $R0 ;counter for $0
603 Push $R1 ;counter for $1
605 Push $4 ;temp string for $0
606 Push $5 ;temp string for $1
614 StrCmp $3 "" DotFound0
615 StrCmp $3 "." DotFound0
623 StrCmp $3 "" DotFound1
624 StrCmp $3 "." DotFound1
632 StrCmp $5 "" Ver2More
633 IntCmp $4 $5 Start Ver2Less Ver2More