Installing the Microsoft .NET Framework: Difference between revisions
(SF: occured -> occurred.) |
m (Updated author and download links, and changed format of some pages.) |
||
Line 214: | Line 214: | ||
Cheers! | Cheers! | ||
Page author: zimsms | Page author: [[User:zimsms|zimsms]] |
Revision as of 12:42, 23 April 2005
Description
I have supplied the following since most people installing the .NET Framework, only choose to install the English version, which may be incorrect for their end users machine. This also contains the proper error handling, which most installs do not use. This 'Template' can be used for pretty much any Microsoft download with a few modifications. I have cut most of the 'extra' languages out to keep the example simple. THIS IS NOT A COMPLETE SCRIPT, IT IS INTENDED TO ASSIST THOSE REQUIRING THE INSTALLATION OF THE .NET FRAMEWORK FOR A MULTI-LANGUAGE INSTALL.
Defines
; .NET Framework ; English !define URL_DOTNET_1033 "http://download.microsoft.com/download/a/a/c/aac39226-8825-44ce-90e3-bf8203e74006/dotnetfx.exe" ; German !define URL_DOTNET_1031 "http://download.microsoft.com/download/4/f/3/4f3ac857-e063-45d0-9835-83894f20e808/dotnetfx.exe" ; Spanish !define URL_DOTNET_1034 "http://download.microsoft.com/download/8/f/0/8f023ff4-2dc1-4f10-9618-333f5b9f8040/dotnetfx.exe" ; French !define URL_DOTNET_1036 "http://download.microsoft.com/download/e/d/a/eda9d4ea-8ec9-4431-8efa-75391fb91421/dotnetfx.exe" ; Portuguese (Brazil) !define URL_DOTNET_1046 "http://download.microsoft.com/download/8/c/f/8cf55d0c-235e-4062-933c-64ffdf7e7043/dotnetfx.exe" ; Chinese (Simplified) !define URL_DOTNET_2052 "http://download.microsoft.com/download/7/b/9/7b90644d-1af0-42b9-b76d-a2770319a568/dotnetfx.exe" ; ... If you need one not listed above you will have to visit the Microsoft Download site, select the language you are after and scan the page source to obtain the link. [/source] Variables: [source] Var "LANGUAGE_DLL_TITLE" Var "LANGUAGE_DLL_INFO" Var "URL_DOTNET" Var "OSLANGUAGE" Var "DOTNET_RETURN_CODE" [/source] Language Strings: [source] LangString DESC_REMAINING ${LANG_ENGLISH} " (%d %s%s remaining)" LangString DESC_PROGRESS ${LANG_ENGLISH} "%d.%01dkB/s" ;"%dkB (%d%%) of %dkB @ %d.%01dkB/s" LangString DESC_PLURAL ${LANG_ENGLISH} "s" LangString DESC_HOUR ${LANG_ENGLISH} "hour" LangString DESC_MINUTE ${LANG_ENGLISH} "minute" LangString DESC_SECOND ${LANG_ENGLISH} "second" LangString DESC_CONNECTING ${LANG_ENGLISH} "Connecting..." LangString DESC_DOWNLOADING ${LANG_ENGLISH} "Downloading %s" LangString DESC_SHORTDOTNET ${LANG_ENGLISH} "Microsoft .Net Framework 1.1" LangString DESC_LONGDOTNET ${LANG_ENGLISH} "Microsoft .Net Framework 1.1" LangString DESC_DOTNET_DECISION ${LANG_ENGLISH} "$(DESC_SHORTDOTNET) is required.$\nIt is strongly advised that you install$\n$(DESC_SHORTDOTNET) before continuing.$\nIf you choose to continue, you will need to connect$\nto the internet before proceeding.$\nWould you like to continue with the installation?" LangString SEC_DOTNET ${LANG_ENGLISH} "$(DESC_SHORTDOTNET) " LangString DESC_INSTALLING ${LANG_ENGLISH} "Installing" LangString DESC_DOWNLOADING1 ${LANG_ENGLISH} "Downloading" LangString DESC_DOWNLOADFAILED ${LANG_ENGLISH} "Download Failed:" LangString ERROR_DOTNET_DUPLICATE_INSTANCE ${LANG_ENGLISH} "The $(DESC_SHORTDOTNET) Installer is already running." LangString ERROR_NOT_ADMINISTRATOR ${LANG_ENGLISH} "$(DESC_000022)" LangString ERROR_INVALID_PLATFORM ${LANG_ENGLISH} "$(DESC_000023)" LangString DESC_DOTNET_TIMEOUT ${LANG_ENGLISH} "The installation of the $(DESC_SHORTDOTNET) has timed out." LangString ERROR_DOTNET_INVALID_PATH ${LANG_ENGLISH} "The $(DESC_SHORTDOTNET) Installation$\nwas not found in the following location:$\n" LangString ERROR_DOTNET_FATAL ${LANG_ENGLISH} "A fatal error occurred during the installation$\nof the $(DESC_SHORTDOTNET)." LangString FAILED_DOTNET_INSTALL ${LANG_ENGLISH} "The installation of $(PRODUCT_NAME) will$\ncontinue. However, it may not function properly$\nuntil $(DESC_SHORTDOTNET)$\nis installed."
Variables
Var "LANGUAGE_DLL_TITLE" Var "LANGUAGE_DLL_INFO" Var "URL_DOTNET" Var "OSLANGUAGE" Var "DOTNET_RETURN_CODE"
Language Strings
LangString DESC_REMAINING ${LANG_ENGLISH} " (%d %s%s remaining)" LangString DESC_PROGRESS ${LANG_ENGLISH} "%d.%01dkB/s" ;"%dkB (%d%%) of %dkB @ %d.%01dkB/s" LangString DESC_PLURAL ${LANG_ENGLISH} "s" LangString DESC_HOUR ${LANG_ENGLISH} "hour" LangString DESC_MINUTE ${LANG_ENGLISH} "minute" LangString DESC_SECOND ${LANG_ENGLISH} "second" LangString DESC_CONNECTING ${LANG_ENGLISH} "Connecting..." LangString DESC_DOWNLOADING ${LANG_ENGLISH} "Downloading %s" LangString DESC_SHORTDOTNET ${LANG_ENGLISH} "Microsoft .Net Framework 1.1" LangString DESC_LONGDOTNET ${LANG_ENGLISH} "Microsoft .Net Framework 1.1" LangString DESC_DOTNET_DECISION ${LANG_ENGLISH} "$(DESC_SHORTDOTNET) is required.$\nIt is strongly advised that you install$\n$(DESC_SHORTDOTNET) before continuing.$\nIf you choose to continue, you will need to connect$\nto the internet before proceeding.$\nWould you like to continue with the installation?" LangString SEC_DOTNET ${LANG_ENGLISH} "$(DESC_SHORTDOTNET) " LangString DESC_INSTALLING ${LANG_ENGLISH} "Installing" LangString DESC_DOWNLOADING1 ${LANG_ENGLISH} "Downloading" LangString DESC_DOWNLOADFAILED ${LANG_ENGLISH} "Download Failed:" LangString ERROR_DOTNET_DUPLICATE_INSTANCE ${LANG_ENGLISH} "The $(DESC_SHORTDOTNET) Installer is already running." LangString ERROR_NOT_ADMINISTRATOR ${LANG_ENGLISH} "$(DESC_000022)" LangString ERROR_INVALID_PLATFORM ${LANG_ENGLISH} "$(DESC_000023)" LangString DESC_DOTNET_TIMEOUT ${LANG_ENGLISH} "The installation of the $(DESC_SHORTDOTNET) has timed out." LangString ERROR_DOTNET_INVALID_PATH ${LANG_ENGLISH} "The $(DESC_SHORTDOTNET) Installation$\nwas not found in the following location:$\n" LangString ERROR_DOTNET_FATAL ${LANG_ENGLISH} "A fatal error occurred during the installation$\nof the $(DESC_SHORTDOTNET)." LangString FAILED_DOTNET_INSTALL ${LANG_ENGLISH} "The installation of $(PRODUCT_NAME) will$\ncontinue. However, it may not function properly$\nuntil $(DESC_SHORTDOTNET)$\nis installed."
Section
Section $(SEC_DOTNET) SECDOTNET SectionIn RO IfSilent lbl_IsSilent !define DOTNETFILESDIR "Common\Files\MSNET" StrCpy $DOTNET_RETURN_CODE "0" !ifdef DOTNET_ONCD_1033 StrCmp "$OSLANGUAGE" "1033" 0 lbl_Not1033 SetOutPath "$PLUGINSDIR" file /r "${DOTNETFILESDIR}\dotnetfx1033.exe" !insertmacro PRINT "$(DESC_INSTALLING) $(DESC_SHORTDOTNET)..." Banner::show /NOUNLOAD "$(DESC_INSTALLING) $(DESC_SHORTDOTNET)..." nsExec::ExecToStack '"$PLUGINSDIR\dotnetfx1033.exe" /q /c:"install.exe /noaspupgrade /q"' pop $DOTNET_RETURN_CODE Banner::destroy SetRebootFlag true Goto lbl_NoDownloadRequired lbl_Not1033: !endif ; Insert Other language blocks here ; the following Goto and Label is for consistencey. Goto lbl_DownloadRequired lbl_DownloadRequired: !insertmacro PRINT "$(DESC_DOWNLOADING1) $(DESC_SHORTDOTNET)..." MessageBox MB_ICONEXCLAMATION|MB_YESNO|MB_DEFBUTTON2 "$(DESC_DOTNET_DECISION)" /SD IDNO IDYES +2 IDNO 0 abort ; "Downloading Microsoft .Net Framework" AddSize 153600 nsisdl::download /TRANSLATE "$(DESC_DOWNLOADING)" "$(DESC_CONNECTING)" \ "$(DESC_SECOND)" "$(DESC_MINUTE)" "$(DESC_HOUR)" "$(DESC_PLURAL)" \ "$(DESC_PROGRESS)" "$(DESC_REMAINING)" \ /TIMEOUT=30000 "$URL_DOTNET" "$PLUGINSDIR\dotnetfx.exe" Pop $0 StrCmp "$0" "success" lbl_continue !insertmacro PRINT "$(DESC_DOWNLOADFAILED) $0" Abort lbl_continue: !insertmacro PRINT "$(DESC_INSTALLING) $(DESC_SHORTDOTNET)..." Banner::show /NOUNLOAD "$(DESC_INSTALLING) $(DESC_SHORTDOTNET)..." nsExec::ExecToStack '"$PLUGINSDIR\dotnetfx.exe" /q /c:"install.exe /noaspupgrade /q"' pop $DOTNET_RETURN_CODE Banner::destroy SetRebootFlag true ; silence the compiler Goto lbl_NoDownloadRequired lbl_NoDownloadRequired: ; obtain any error code and inform the user ($DOTNET_RETURN_CODE) ; If nsExec is unable to execute the process, ; it will return "error" ; If the process timed out it will return "timeout" ; else it will return the return code from the executed process. StrCmp "$DOTNET_RETURN_CODE" "" lbl_NoError StrCmp "$DOTNET_RETURN_CODE" "0" lbl_NoError StrCmp "$DOTNET_RETURN_CODE" "3010" lbl_NoError StrCmp "$DOTNET_RETURN_CODE" "8192" lbl_NoError StrCmp "$DOTNET_RETURN_CODE" "error" lbl_Error StrCmp "$DOTNET_RETURN_CODE" "timeout" lbl_TimeOut ; It's a .Net Error StrCmp "$DOTNET_RETURN_CODE" "4101" lbl_Error_DuplicateInstance StrCmp "$DOTNET_RETURN_CODE" "4097" lbl_Error_NotAdministrator StrCmp "$DOTNET_RETURN_CODE" "1633" lbl_Error_InvalidPlatform lbl_FatalError ; all others are fatal lbl_Error_DuplicateInstance: !insertmacro PRINT "$(ERROR_DOTNET_DUPLICATE_INSTANCE)" GoTo lbl_Done lbl_Error_NotAdministrator: !insertmacro PRINT "$(ERROR_NOT_ADMINISTRATOR)" GoTo lbl_Done lbl_Error_InvalidPlatform: !insertmacro PRINT "$(ERROR_INVALID_PLATFORM)" GoTo lbl_Done lbl_TimeOut: !insertmacro PRINT "$(DESC_DOTNET_TIMEOUT)" GoTo lbl_Done lbl_Error: !insertmacro PRINT "$(ERROR_DOTNET_INVALID_PATH)" GoTo lbl_Done lbl_FatalError: !insertmacro PRINT "$(ERROR_DOTNET_FATAL)[$DOTNET_RETURN_CODE]" GoTo lbl_Done lbl_Done: !insertmacro PRINT "$(FAILED_DOTNET_INSTALL)" lbl_NoError: lbl_IsSilent: SectionEnd !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SECDOTNET} $(DESC_LONGDOTNET) !insertmacro MUI_FUNCTION_DESCRIPTION_END
This requires some setup in .OnInit:
Function .onInit StrCpy $LANGUAGE_DLL_TITLE "Installer Language" StrCpy $LANGUAGE_DLL_INFO "Please select a language:" StrCpy $URL_DOTNET "${URL_DOTNET_1033}" StrCpy $OSLANGUAGE "1033" ; Insert other Language Blocks Here !define MUI_LANGDLL_WINDOWTITLE "$LANGUAGE_DLL_TITLE" !define MUI_LANGDLL_INFO "$LANGUAGE_DLL_INFO" !insertmacro MUI_LANGDLL_DISPLAY !undef MUI_LANGDLL_WINDOWTITLE !undef MUI_LANGDLL_INFO InitPluginsDir SetOutPath "$PLUGINSDIR" File "Common\Plugins\*.*" File /r "${NSISDIR}\Plugins\*.*" FunctionEnd
I test for IsDotNetInstalled by defining a custom function overriding GUI Init, and set the section selection accordingly. Hopefully this was of use to you. Cheers!
Page author: zimsms