Quiero crear un instalador NSIS que busque el .NET Framework y lo instale si no está allí. ¿Puedes indicarme un guión para esto? Soy muy nuevo en NSIS.Instalador NSIS que busca .NET Framework
Respuesta
!define DOT_MAJOR "2"
!define DOT_MINOR "0"
Function IsDotNetInstalled
StrCpy $0 "0"
StrCpy $1 "SOFTWARE\Microsoft\.NETFramework" ;registry entry to look in.
StrCpy $2 0
StartEnum:
;Enumerate the versions installed.
EnumRegKey $3 HKLM "$1\policy" $2
;If we don't find any versions installed, it's not here.
StrCmp $3 "" noDotNet notEmpty
;We found something.
notEmpty:
;Find out if the RegKey starts with 'v'.
;If it doesn't, goto the next key.
StrCpy $4 $3 1 0
StrCmp $4 "v" +1 goNext
StrCpy $4 $3 1 1
;It starts with 'v'. Now check to see how the installed major version
;relates to our required major version.
;If it's equal check the minor version, if it's greater,
;we found a good RegKey.
IntCmp $4 ${DOT_MAJOR} +1 goNext yesDotNetReg
;Check the minor version. If it's equal or greater to our requested
;version then we're good.
StrCpy $4 $3 1 3
IntCmp $4 ${DOT_MINOR} yesDotNetReg goNext yesDotNetReg
goNext:
;Go to the next RegKey.
IntOp $2 $2 + 1
goto StartEnum
yesDotNetReg:
;Now that we've found a good RegKey, let's make sure it's actually
;installed by getting the install path and checking to see if the
;mscorlib.dll exists.
EnumRegValue $2 HKLM "$1\policy\$3" 0
;$2 should equal whatever comes after the major and minor versions
;(ie, v1.1.4322)
StrCmp $2 "" noDotNet
ReadRegStr $4 HKLM $1 "InstallRoot"
;Hopefully the install root isn't empty.
StrCmp $4 "" noDotNet
;build the actuall directory path to mscorlib.dll.
StrCpy $4 "$4$3.$2\mscorlib.dll"
IfFileExists $4 yesDotNet noDotNet
noDotNet:
;Nope, something went wrong along the way. Looks like the proper .NETFramework isn't installed.
Push "NOK"
Return
yesDotNet:
;Everything checks out. Go on with the rest of the installation.
Push "OK"
Return
FunctionEnd
El siguiente código verifica si está instalado .Net 3.5, y si no, lo instalará en silencio. Utiliza una macro que verifica si existe una clave especificada en el registro.
La macro:
# This macro checks if a certain key exists in the registry
!macro IfKeyExists ROOT MAIN_KEY KEY
push $R0
push $R1
!define Index 'Line${__LINE__}'
StrCpy $R1 "0"
"${Index}-Loop:"
; Check for Key
EnumRegKey $R0 ${ROOT} "${MAIN_KEY}" "$R1"
StrCmp $R0 "" "${Index}-False"
IntOp $R1 $R1 + 1
StrCmp $R0 "${KEY}" "${Index}-True" "${Index}-Loop"
"${Index}-True:"
;Return 1 if found
push "1"
goto "${Index}-End"
"${Index}-False:"
;Return 0 if not found
push "0"
goto "${Index}-End"
"${Index}-End:"
!undef Index
exch 2
pop $R0
pop $R1
!macroend
La función:
# The function that checks if .net is already installed
Function CheckDotNet
!insertmacro IfKeyExists HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "{CE2CDD62-0124-36CA-84D3-9F4DCF5C5BD9}"
Pop $R0
${If} $R0 == 0 # not installed NOTE: /q:a means this will be a silent installation
ExecWait "$EXEDIR\dotnetfx35.exe /q:a"
Goto endPrerequisites
${EndIf}
endPrerequisites:
# Code to execute after checking/installing (if necessary) .Net
# You can just put "Goto +2" here, in order to go to the next section/function
FunctionEnd
Para que esto funcione, usted tiene que llamar CheckDotNet
en algún lugar de la función .onInit
y asegúrese de que dotnetfx35.exe
se empaqueta en su instalador en el $EXEDIR
(por supuesto puede cambiar el e parámetros que desee).
Para otras versiones de .Net, supongo que la única cosa diferente será la clave de registro especificada en el parámetro de macro IfKeyExists
(ahora es {CE2CDD62-0124-36CA-84D3-9F4DCF5C5BD9}
)
ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client" Install
Entonces usted debe comprobar $0
. Depende de ti cómo.
¿Qué considera que esto agrega en comparación con las otras respuestas? No dice lo que debería ser, ni va a instalarlo. –
tuve un problema con el pluging "DotNET.nsh", que se puede encontrar somwhere, y simplemente se utiliza esta solución (para .NET 4.0, la instalación completa - lo que necesitaba, puede así limitar a el paquete de cliente):
ClearErrors
ReadRegDWORD $0 HKLM "Software\Microsoft\Net Framework Setup\NDP\v4\Full" "Install"
IfErrors dotNet40NotFound
IntCmp $0 1 dotNet40Found
dotNet40NotFound:
Banner::show /set 76 "Installing .NET Framework 4.0" "Please wait"
File /nonfatal "tools\dotNetFx40_Full_setup.exe"
; if you don't have $TEMP already, add here:
; SetOutPath $TEMP
ExecWait "$TEMP\dotNetFx40_Full_setup.exe /passive /norestart"
Delete /REBOOTOK "$TEMP\dotNetFx40_Full_setup.exe"
Banner::destroy
dotNet40Found:
la materia bandera es opcional, sólo se podía utilizar DetailPrint
o similares. De esta manera, extrae el instalador Web para .NET 4.0, pero es bastante pequeño (en comparación con las versiones de .NET que no tenían uno). El instalador realiza la descarga si es necesario y no necesita kilómetros de código NSIS.
Probablemente no sea la razón correcta para un voto positivo, pero este código de script tiene más sentido para mí que cualquier otro ejemplo de hacerlo. Gracias. –
Pruebe la secuencia de comandos DotNetVer. Utiliza LogicLib y es bastante fácil de usar.
- HasDotNet < versión > comprueba si se ha instalado la versión específica del marco .NET. < versión > se puede reemplazar con los siguientes valores: 1.0, 1.1, 2.0, 3.0, 3.5, 4.0.
- AtLeastDotNetServicePack comprueba si .NET framework tiene una versión del paquete de servicio al menos como se especifica.
- IsDotNetServicePack comprueba si .NET Framework tiene una versión de paquete de servicio exactamente como se especifica.
- HasDotNetClientProfile comprueba si .NET framework es una instalación con perfil de cliente.
- HasDotNetFullProfile comprueba si.NET Framework es una instalación completa.
muestra:
${If} ${HasDotNet4.0} DetailPrint "Microsoft .NET Framework 4.0 installed." ${If} ${DOTNETVER_4_0} AtLeastDotNetServicePack 1 DetailPrint "Microsoft .NET Framework 4.0 is at least SP1." ${Else} DetailPrint "Microsoft .NET Framework 4.0 SP1 not installed." ${EndIf} ${If} ${DOTNETVER_4_0} HasDotNetClientProfile 1 DetailPrint "Microsoft .NET Framework 4.0 (Client Profile) available." ${EndIf} ${If} ${DOTNETVER_4_0} HasDotNetFullProfile 1 DetailPrint "Microsoft .NET Framework 4.0 (Full Profile) available." ${EndIf} ${If} ${DOTNETVER_4_0} HasDotNetFullProfile 0 DetailPrint "Microsoft .NET Framework 4.0 (Full Profile) not available." ${EndIf} ${EndIf}
Si usted está buscando opciones con .NET Framework 4.0 o superior (y superior) incluyendo
- .NET 4.5
- .NET 4.5.1
revise este plug-in para NSIS: DotNetChecker
- 1. Instalador NSIS con .NET 4.0
- 2. NSIS Nombre del instalador
- 3. Instalador de Sign NSIS en Linux box
- 4. NSIS Indicador de error del instalador
- 5. NSIS Installer con .NET 4.5
- 6. ¿Cómo ejecutar un desinstalador de NSIS desde otro instalador de NSIS y esperar a que termine?
- 7. Eliminación de la marca del instalador NSIS
- 8. NSIS - poner versión EXE en nombre del instalador
- 9. NSIS: Buscar y descargar la versión .Net
- 10. Ejecutar archivo por lotes en el instalador NSIS
- 11. ¿Cómo se hace un instalador de actualización con NSIS?
- 12. Configuración del campo 'Publicador' de UAC para un instalador NSIS
- 13. Modificación de las propiedades del instalador de NSIS
- 14. ¿Cómo reemplazar el logotipo predeterminado en el instalador de NSIS?
- 15. ¿Cómo es que el instalador fuera de línea .NET Framework 3.5 tiene 200 MB más que el instalador .NET 4 sin conexión?
- 16. DirectX administrado que se ejecuta desde la aplicación .Net Framework 4.0 no busca
- 17. ¿Por qué el tamaño del instalador de .NET Framework 4.0 es más pequeño que 3.0/3.5?
- 18. ¿Incluye .Net Framework 4.0 Installer el .Net Framework 3.5?
- 19. NSIS obtener la ruta del archivo instalador actual que se está ejecutando
- 20. .NET 2.0 incluye en .NET 3.5 instalador?
- 21. Winform sin .NET framework?
- 22. Orientación de .NET Framework 3.5, utilizando .NET 2.0 Runtime. ¿Advertencias?
- 23. ¿Cómo puedo hacer un instalador de WiX 3.5 con un instalador de .NET 4.0 completamente autónomo?
- 24. ¿Requiere Silverlight que se instale .NET Framework?
- 25. ¿Dónde puedo descargar el instalador autónomo REAL .Net Framework 4 completo?
- 26. Número de versión .NET (versión del instalador)
- 27. Agrupación de .NET en el instalador
- 28. ¿El instalador .NET 3.5 incluye 3.0 SP2?
- 29. Instalador como InnoSetup para Mac
- 30. NSIS - Cómo incluir todas las carpetas de la fuente al Instalador
Hmm, ¡estoy interesado en esto también! –
Hay varios ejemplos en [Wiki de NSIS] (http://nsis.sourceforge.net/Main_Page). Pruebe [este] (http://nsis.sourceforge.net/DotNET). –
Aquí está la manera de verificar qué versión está instalada inténtalo http://forums.winamp.com/showthread.php?t=324928 – dastanko