The .NET Framework Checker NSIS plugin is used to detect if the required .NET Framework is installed and if it is not - plugin will download and install the required package. The plugin's C++ source code is based on the work of Aaron Stebner.
bin
- compiled NSIS plugin (ready-to-use)plugin
- contains source code for building DotNetChecker plugin in Visual Studio 2010nsis
- contains CheckNetFramework macros (DotNetChecker.nsh) and example NSIS installation file
- Copy
DotNetChecker.dll
to NSIS plugins directory (usuallyC:\Program Files\Nsis\Plugins\
orC:\Program Files (x86)\Nsis\Plugins\
) - Add to your installer project
DotNetChecker.nsh
file - Reference
DotNetChecker.nsh
in your main NSI file like this:!include "DotNetChecker.nsh"
- Insert macros with the version of required .NET framework.
- Copy the whole project in to the same folder as your NSIS Script.
- Refrence the Plugin DLL like this:
!addplugindir "NsisDotNetChecker\bin"
- Reference
DotNetChecker.nsh
in your main NSI file like this:!include "NsisDotNetChecker\nsis\DotNetChecker.nsh"
The Plugin and its Macro(s) can be invoked by any Function or within any Section of the NSI script.
Only one macro needs to be used:
CheckNetFramework
will reboot if required in the middle of the macro
CheckNetFrameworkDelayRestart
overrides a reboot, and returns "true" if an installer was run.
!insertmacro CheckNetFramework 481
!insertmacro CheckNetFrameworkDelayRestart 481 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 48
!insertmacro CheckNetFrameworkDelayRestart 48 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 472
!insertmacro CheckNetFrameworkDelayRestart 472 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 471
!insertmacro CheckNetFrameworkDelayRestart 471 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 47
!insertmacro CheckNetFrameworkDelayRestart 47 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 462
!insertmacro CheckNetFrameworkDelayRestart 462 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 461
!insertmacro CheckNetFrameworkDelayRestart 461 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 46
!insertmacro CheckNetFrameworkDelayRestart 46 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 452
!insertmacro CheckNetFrameworkDelayRestart 452 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 451
!insertmacro CheckNetFrameworkDelayRestart 451 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 45
!insertmacro CheckNetFrameworkDelayRestart 45 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 40Client
!insertmacro CheckNetFrameworkDelayRestart 40Client $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 40Full
!insertmacro CheckNetFrameworkDelayRestart 40Full $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 35 ; if your application targets .NET 3.5 Framework
!insertmacro CheckNetFrameworkDelayRestart 35 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 30 ; if your application targets .NET 3.0 Framework
!insertmacro CheckNetFrameworkDelayRestart 30 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 20 ; if your application targets .NET 2.0 Framework
!insertmacro CheckNetFrameworkDelayRestart 20 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 11 ; if your application targets .NET 1.1 Framework
!insertmacro CheckNetFrameworkDelayRestart 11 $0 ; Returns if an install was performed
!insertmacro CheckNetFramework 10 ; if your application targets .NET 1.0 Framework
!insertmacro CheckNetFrameworkDelayRestart 10 $0 ; Returns if an install was performed
NB: Script will download .NET 3.5 for both .NET 3.0 and .NET 3.5 requirements. The same rule applies to .NET 1.1 and .NET 1.0. If you want to change this behavior - feel free to edit DotNetChecker.nsh.
NB2: Plugin is also capable of detecting Framework Service Pack Level. To use this functionality, just call one of the corresponding functions (i.e. DotNetChecker::GetDotNet11ServicePack).
The return value (Pop $0) will be:
-
-2 if framework is not installed
-
-1 if no service pack installed for this framework
-
some positive int value otherwise
NB3: Plugin works not only in UNICODE but also in ANSI scripts.
NB4: The plugin can be called more than once for installing two (or more) different versions of framework.