NSIS installer that checks for .NET Framework

omgwtfbbq picture omgwtfbbq · Sep 18, 2009 · Viewed 10.6k times · Source

I want to create an NSIS installer that checks for the .NET Framework and installs it if it's not there. Can you point me to a script for this? I'm very new to NSIS.

Answer

Spiralis picture Spiralis · Apr 26, 2012

Try the DotNetVer script. It uses LogicLib and is quite easy to use.

  • HasDotNet<version> checks if the specific version of .NET framework is installed. <version> can be replaced with the following values: 1.0, 1.1, 2.0, 3.0, 3.5, 4.0.
  • AtLeastDotNetServicePack checks if the .NET framework has a service pack version at least as specified.
  • IsDotNetServicePack checks if the .NET framework has a service pack version exactly as specified.
  • HasDotNetClientProfile checks if the .NET framework is a client profiled install.
  • HasDotNetFullProfile checks if the .NET framework is a full install.

Sample:

${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}