Using NSIS is a little more inconvenient than using Microsoft Visual Studio's Setup and Deployment project - for one thing files and dependencies must be typed into a script file, and the .NET framework dependency must be handled manually.
I found a NSIS plug-in for checking and installing the .NET framework from this web site https://github.com/ProjectHuman/NsisDotNetChecker. Just follow the instructions on the website to install it on your machine and use it in the NSIS script. However, the script DotNetChecker.nsh that you have to include in your script has a problem and must be edited. If the DotNetChecker.nsh script is used as is, then your installer will never be able to detect and install the .NET framework.
The following change must be made to the DotNetChecker.nsh include script.
- Open up the file DotNetChecker.nsh in a text editor.
- Locate the following line:
${If} $0 == "false" - Replace false with f as shown below:
${If} $0 == "f" - Save and close the file.
Now the installer built with this modified DotNetChecker.nsh script will be able to detect and install the .NET framework if necessary.