Suchen Sie mit NSIS nach .NET4.5 +
Insgesamt sind mir die folgenden Methoden zur Überprüfung der Framework-Version in NSIS bekannt. Für .NET4.0 + verwende ich derzeit
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 "Hierfür wird der Registrierungspfad / -eintrag 'HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ NET Framework-Setup \ NDP' verwendet. Dies funktioniert nun auch, da sich der Eintrag nicht von .NET4.0 auf 4.5 ändert. Ich stelle fest, dass es einen Eintrag mit dem Namen 'HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft.NETFramework \ v4.0.30319 \ SKUs.NETFramework, Version = v4.5' gibt. Kann ich damit die Framework-Version ausnahmslos überprüfen?3.$2\mscorlib.dll"
IfFileExists $4 yesDotNet noDotNet
noDotNet:
; No, something went wrong along the way. Looks like the
; proper .NET Framework isn't installed.
MessageBox MB_ICONEXCLAMATION "To install UserCost, Microsoft's .NET Framework v${DOT_MAJOR}.${DOT_MINOR} \
(or higher) must be installed. Cannot proceed with the installation!"
${OpenURL} "${WWW_MS_DOTNET4}"
Abort
yesDotNet:
; Everything checks out. Proceed with the rest of the installation.
FunctionEnd
Dies funktioniert sehr gut für .NET4.0, aber ich habe meine Anwendung jetzt erweitert, um das zu nutzenasync
/await
Funktionen und anschließend müssen Benutzer .NET4.5 + installieren. Die obige Methode ist nicht geeignet, da bei der Installation für .NET4.5 der Registrierungspfad "HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft.NETFramework \ Policy" nicht verwendet wird, um neue Informationen zu speichern Änderungen zwischen .NET4.0 und 4.5 Jetzt habe ich die folgenden Beiträge gesehen:
Hierfür wird der Registrierungspfad / -eintrag 'HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ NET Framework-Setup \ NDP' verwendet. Dies funktioniert nun auch, da sich der Eintrag nicht von .NET4.0 auf 4.5 ändert. Ich stelle fest, dass es einen Eintrag mit dem Namen 'HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft.NETFramework \ v4.0.30319 \ SKUs.NETFramework, Version = v4.5' gibt. Kann ich damit die Framework-Version ausnahmslos überprüfen?
Gibt es eine offizielle Möglichkeit, mit NSIS nach .NET4.5 zu suchen?
Vielen Dank für Ihre Zeit.
Hinweis: In der Folge hatte eine Installation von .NET4.5, die meine Benutzer durchgeführt haben, Registrierungswerte für
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
Ein DWORD-Wert mit dem NamenRelease
war nicht378389
aber378181
. Durch diese Änderung schien das Problem als Eintrag für die behoben zu seinRelease
ist nicht in der Registrierung für .NET4.5 und darunter.