Alle, ich kenne die folgenden Methoden, um die Framework-Version in NSIS zu überprüfen. Für .NET4.0 + zur Zeit ichNach .NET4.5 + mit NSIS suchen
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:
; 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
verwenden sehr gut Dies funktioniert für .NET4.0, aber ich habe jetzt meine Anwendung erweitert die async
/await
Funktionen zu nutzen und anschließend müssen die Benutzer .NET4.5 installieren +. Die obige Methode ist nicht geeignet, da die Installation für .NET 4.5 jetzt nicht den Registrierungspfad "HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft.NETFramework \ Policy" verwendet, um neue Informationen zu speichern, das heißt, dieser Pfad scheint keinen Wert zu enthalten Änderungen zwischen .NET4.0 und 4,5 Jetzt habe ich die folgenden Beiträge zu sehen.
, die den Registrierungspfad/Eintrag 'HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ NET Framework Setup \ NDP' verwendet, um die Kontrollen zu tun Jetzt funktioniert das auch, da sich der Eintrag nicht von .NET4 auf 4.5 ändert Ich bemerke, dass es einen Eintrag namens 'HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft.NETFramework \ v4.0.30319 \ SKUs.NETFramework, Version = v4 gibt. 5 'kann ich dies verwenden, um die Framework-Version ausnahmslos zu überprüfen?
Gibt es eine offizielle Möglichkeit, nach .NET4 mit NSIS zu suchen?
Danke für Ihre Zeit.
Hinweis: anschließend einige Installation von .NET4.5 meine Benutzer haben mussten auf Registry-Werte durchgeführt
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
ein DWORD-Wert mit dem Namen Release
war nicht 378389
aber 378181
. Diese Änderung schien das Problem zu lösen, da der Eintrag für Release
nicht in der Registrierung für .NET4.5 und niedriger ist.
Das ist eine Qualitätsantwort. Wo werden diese Informationen von Microsoft zur Verfügung gestellt - oder sollen wir selbst herausfinden? Danke für Ihre Zeit ... – MoonKnight
Ich habe vergessen, die [Quelle] (http://msdn.microsoft.com/en-us/library/hh925568.aspx) zu verweisen. –
Ich habe es gerade gefunden. Danke nochmal ... – MoonKnight