简体   繁体   English

带有.NET 4.5的NSIS安装程序

[英]NSIS Installer with .NET 4.5

I'm after some code snippets for NSIS to detect and conditionally run the .NET 4.5 installer 我正在为NSIS提供一些代码片段,以检测并有条件地运行.NET 4.5安装程序

This answer - NSIS Installer with .NET 4.0 - is too naive as checking only the presense of the registry key (not the value) will not discriminate between 4.0 and 4.5 这个答案 - 带有.NET 4.0的NSIS安装程序 - 太天真了,因为只检查注册表项(而不是值)的存在不会区分4.0和4.5

You shouldn't check for an exact version number. 您不应该检查确切的版本号。 This will change in the future (as was the case for 4.0 > 4.5). 这将在未来发生变化(如4.0> 4.5的情况)。 Instead use the codes from the deployment guide . 而是使用部署指南中的代码。

In addition to that you should try to handle the reboot from .Net 4.5. 除此之外,您应该尝试从.Net 4.5处理重启。

Function CheckAndInstallDotNet
    ; Magic numbers from http://msdn.microsoft.com/en-us/library/ee942965.aspx
    ClearErrors
    ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" "Release"

    IfErrors NotDetected

    ${If} $0 >= 378389

        DetailPrint "Microsoft .NET Framework 4.5 is installed ($0)"
    ${Else}
    NotDetected:
        DetailPrint "Installing Microsoft .NET Framework 4.5"
        SetDetailsPrint listonly
        ExecWait '"$INSTDIR\Tools\dotNetFx45_Full_setup.exe" /passive /norestart' $0
        ${If} $0 == 3010 
        ${OrIf} $0 == 1641
            DetailPrint "Microsoft .NET Framework 4.5 installer requested reboot"
            SetRebootFlag true
        ${EndIf}
        SetDetailsPrint lastused
        DetailPrint "Microsoft .NET Framework 4.5 installer returned $0"
    ${EndIf}

FunctionEnd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM