Windows NSIS installer

Having trouble installing or compiling FreeCAD? Get help here.
User avatar
sgrogan
Posts: 5330
Joined: Wed Oct 22, 2014 5:02 pm

Windows NSIS installer

Postby sgrogan » Mon Apr 11, 2016 9:41 pm

I'm trying to build an NSIS windows installer using the .bat files from FreeCad/src/WindowsInstaller
It looks the scripts expect an in-source build. Will just copying the contents of the libpack/bin directory to bin work?
I changed python26 to python27 in BuildNSISInstaller.bat and commented out
Line 10

Code: Select all

SET /P M=Reebuild and press enter 
peterl94
Posts: 999
Joined: Thu May 23, 2013 7:31 pm
Location: United States

Re: Windows NSIS installer

Postby peterl94 » Mon Apr 11, 2016 10:31 pm

You know, I think I made some changes to that script last time, but I must of forgot about it before submitting a pull request... I'll go check.
peterl94
Posts: 999
Joined: Thu May 23, 2013 7:31 pm
Location: United States

Re: Windows NSIS installer

Postby peterl94 » Tue Apr 12, 2016 2:15 am

Okay, so this is what I did (I must of not wanted to bother with actually fixing the build folder problem):

1. Copied the [source dir]/src/WindowsInstaller folder to [build dir]/src/WindowsInstaller
2. Copied Version.nsi.in to Version.in and filled in the information
3. Copied the appropriate vcredist exe to the [build dir]/src/WindowsInstaller folder
4. Replaced License.rtf with the LGPL
5. Ran BuildNSISInstaller.bat in [build dir]/src/WindowsInstaller (probably commented out the lines running the version script)

Note: in [build dir]/bin I only had the release versions of the libraries. I assume the installer script has the necessary file filters, but I didn't confirm that.

And here are the patches:

Code: Select all

diff --git a/src/WindowsInstaller/FreeCAD_WindowsInstaller.nsi b/src/WindowsInstaller/FreeCAD_WindowsInstaller.nsi
index 21ca220..abae256 100644
--- a/src/WindowsInstaller/FreeCAD_WindowsInstaller.nsi
+++ b/src/WindowsInstaller/FreeCAD_WindowsInstaller.nsi
@@ -48,7 +48,7 @@ LicenseData "License.rtf"
 # This will be in the installer/uninstaller's title bar
 Name "${FULLNAME}"
 #Icon "logo.ico"
-outFile "..\..\${FULLNAME}.${VERSIONBUILD}_x86_unstable_setup.exe"
+outFile "..\..\${APPNAME}-${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}_x86_setup.exe"
  
 !include LogicLib.nsh
  
@@ -87,7 +87,11 @@ section "install"
     file  "vcredist_x86.exe"
 	
 	# Install the Visual Studio redistributable 
+    ${If} $%VCVERSION% == "VC9"
         ExecWait '"$INSTDIR\vcredist_x86.exe" /q:a /c:"VCREDI~1.EXE /q:a /c:""msiexec /i vcredist.msi /qb!"" "'
+    ${Else}
+        ExecWait '"$INSTDIR\vcredist_x86.exe" /passive /norestart'
+    ${EndIf}
     
 	# Uninstaller - See function un.onInit and section "uninstall" for configuration
 	writeUninstaller "$INSTDIR\uninstall.exe"
@@ -124,7 +128,7 @@ function un.onInit
 	SetShellVarContext all
  
 	#Verify the uninstaller - last chance to back out
-	MessageBox MB_OKCANCEL "Permanantly remove ${APPNAME}?" /SD IDOK IDOK next
+	MessageBox MB_OKCANCEL "Permanantly remove ${APPNAME}?" IDOK next
 		Abort
 	next:
 	!insertmacro VerifyUserIsAdmin
diff --git a/src/WindowsInstaller/FreeCAD_x64_WindowsInstaller.nsi b/src/WindowsInstaller/FreeCAD_x64_WindowsInstaller.nsi
index 184d922..be75e0b 100644
--- a/src/WindowsInstaller/FreeCAD_x64_WindowsInstaller.nsi
+++ b/src/WindowsInstaller/FreeCAD_x64_WindowsInstaller.nsi
@@ -50,7 +50,7 @@ InstallDir "$PROGRAMFILES64\${FULLNAME}"
 # This will be in the installer/uninstaller's title bar
 Name "${FULLNAME}"
 #Icon "logo.ico"
-outFile "..\..\${INSTNAME}.${VERSIONBUILD}_x64_unstable_setup.exe"
+outFile "..\..\${INSTNAME}.${VERSIONBUILD}_x64_setup.exe"
 
 #Interface Settings
 !define MUI_ABORTWARNING
@@ -102,7 +102,7 @@ section "FreeCAD (Required)"
     file  "vcredist_x64.exe"
 
 	# Install the Visual Studio redistributable 
-    ExecWait '"$INSTDIR\vcredist_x64.exe" /q:a /c:"VCREDI~1.EXE /q:a /c:""msiexec /i vcredist.msi /qb!"" "'
+    ExecWait '"$INSTDIR\vcredist_x64.exe" /passive /norestart'
 
 	# Uninstaller - See function un.onInit and section "uninstall" for configuration
 	WriteUninstaller "$INSTDIR\Uninstall.exe"
@@ -159,7 +159,7 @@ function un.onInit
 	SetShellVarContext all
 
 	#Verify the uninstaller - last chance to back out
-	MessageBox MB_OKCANCEL "Permanantly remove ${APPNAME}?" /SD IDOK IDOK next
+	MessageBox MB_OKCANCEL "Permanantly remove ${APPNAME}?" IDOK next
 		Abort
 	next:
 	!insertmacro VerifyUserIsAdmin
I changed the batch file depending on the architecture:

x86:

Code: Select all

diff --git a/src/WindowsInstaller/BuildINSISInstaller.bat b/src/WindowsInstaller/BuildINSISInstaller.bat
index b1f6fe7..eca6ee1 100644
--- a/src/WindowsInstaller/BuildINSISInstaller.bat
+++ b/src/WindowsInstaller/BuildINSISInstaller.bat
@@ -3,9 +3,10 @@ if NOT DEFINED NSIS set NSIS=C:\Program Files (x86)\NSIS
 
 rem in order to build an x64 installer set PLATFORM to x64 
 if not defined PLATFORM set PLATFORM=x86
+set VCVERSION=VC9
 
-C:\Python26\python.exe ../Tools/WinVersion.py --dir=../.. --src=Version.nsi.in --out=Version.nsi
-C:\Python26\python.exe ../Tools/WinVersion.py --dir=../.. --src=../Build/Version.h.in   --out=../Build/Version.h
+C:\Python27\python.exe ../Tools/WinVersion.py --dir=../.. --src=Version.nsi.in --out=Version.nsi
+C:\Python27\python.exe ../Tools/WinVersion.py --dir=../.. --src=../Build/Version.h.in   --out=../Build/Version.h
 
 SET /P M=Reebuild and press enter 
 
x64:

Code: Select all

diff --git a/src/WindowsInstaller/BuildINSISInstaller.bat b/src/WindowsInstaller/BuildINSISInstaller.bat
index b1f6fe7..53895ae 100644
--- a/src/WindowsInstaller/BuildINSISInstaller.bat
+++ b/src/WindowsInstaller/BuildINSISInstaller.bat
@@ -2,12 +2,12 @@
 if NOT DEFINED NSIS set NSIS=C:\Program Files (x86)\NSIS
 
 rem in order to build an x64 installer set PLATFORM to x64 
-if not defined PLATFORM set PLATFORM=x86
+if not defined PLATFORM set PLATFORM=x64
 
-C:\Python26\python.exe ../Tools/WinVersion.py --dir=../.. --src=Version.nsi.in --out=Version.nsi
-C:\Python26\python.exe ../Tools/WinVersion.py --dir=../.. --src=../Build/Version.h.in   --out=../Build/Version.h
+C:\Python27\python.exe ../Tools/WinVersion.py --dir=../.. --src=Version.nsi.in --out=Version.nsi
+C:\Python27\python.exe ../Tools/WinVersion.py --dir=../.. --src=../Build/Version.h.in   --out=../Build/Version.h
 
 SET /P M=Reebuild and press enter 
 
-"%NSIS%\makensis.exe" FreeCAD_WindowsInstaller.nsi
+"%NSIS%\makensis.exe" FreeCAD_x64_WindowsInstaller.nsi
 
Attachments
License.rtf.zip
(74.66 KiB) Downloaded 38 times
Last edited by peterl94 on Tue Apr 12, 2016 2:22 am, edited 1 time in total.
peterl94
Posts: 999
Joined: Thu May 23, 2013 7:31 pm
Location: United States

Re: Windows NSIS installer

Postby peterl94 » Tue Apr 12, 2016 2:20 am

So to answer your actual question, I think copying the necessary build folders (bin, lib, Mod, data) to the src folder would work , I just did it the other way around.
wmayer
Site Admin
Posts: 14782
Joined: Thu Feb 19, 2009 10:32 am

Re: Windows NSIS installer

Postby wmayer » Tue Apr 12, 2016 7:13 am

When I created installers with NSIS in the past then I:
  1. Made sure that cmake's CMAKE_INSTALL_PREFIX points to a directory where I have write access to
  2. Executed the INSTALL target inside VisualStudio. This copies only the files we really need and keeps out of the installer all the junk files you may get with an in-source build
  3. Create a directory structure src/WindowsInstaller on the installation directory and copy over the NSIS files. Set the version number in Version.nsi
  4. From the Libpack you have to copy all dlls and external Python modules. This takes some time to find only the required files
  5. Start the NSIS application and load the .nsi script
  6. Try the installation and run the self-tests to see that all files got picked up
User avatar
sgrogan
Posts: 5330
Joined: Wed Oct 22, 2014 5:02 pm

Re: Windows NSIS installer

Postby sgrogan » Tue Apr 12, 2016 11:43 am

Great! Thanks guys, I was sort of on the right track. I think I should have it now.
User avatar
sgrogan
Posts: 5330
Joined: Wed Oct 22, 2014 5:02 pm

Re: Windows NSIS installer

Postby sgrogan » Tue Apr 12, 2016 11:28 pm

First shot is here: https://github.com/sgrogan/FreeCAD/rele ... g/0.16-rc1
FreeCAD froze from the test install from within NSIS. During FreeCAD Self-test
x64-release-Self-test.PNG
x64-release-Self-test.PNG (169.77 KiB) Viewed 2391 times
Killing FreeCAD and NSIS after that and reinstalling. No Self-test failures.
When the vcredist is installing there is a long delay. @peterl94, you had I pop-up here? I thought the installer had hanged but it was just the redist, click the details tab.
Uninstall seems to work, the redist is deleted and thus the FreeCAD 0.16 folder. Should we replace the [space] with an underscore? I do not know how to test the silent install/uninstall but I see that wmayer has made improvements here.
If anybody who tests can report virus detection failures that would be appreciated. There were some false positives for 0.15 that I reported to the various virus scanners, that were white listed.
My first installer, let the stones fly :)
peterl94
Posts: 999
Joined: Thu May 23, 2013 7:31 pm
Location: United States

Re: Windows NSIS installer

Postby peterl94 » Wed Apr 13, 2016 12:36 am

I'm not sure the redist actually installed. I get a missing MSVCP120 dll message when installing on a clean win install. I think that is why I changed this line:

Code: Select all

    # Install the Visual Studio redistributable 
-    ExecWait '"$INSTDIR\vcredist_x64.exe" /q:a /c:"VCREDI~1.EXE /q:a /c:""msiexec /i vcredist.msi /qb!"" "'
+    ExecWait '"$INSTDIR\vcredist_x64.exe" /passive /norestart'
User avatar
sgrogan
Posts: 5330
Joined: Wed Oct 22, 2014 5:02 pm

Re: Windows NSIS installer

Postby sgrogan » Wed Apr 13, 2016 8:01 pm

peterl94 wrote:I'm not sure the redist actually installed. I get a missing MSVCP120 dll message when installing on a clean win install. I think that is why I changed this line:
Thanks Peter!
RC2 is up at the previous link. If you guys like it I'll move it to the FreeCAD release page as RC2 and advertise.
User avatar
sgrogan
Posts: 5330
Joined: Wed Oct 22, 2014 5:02 pm

Re: Windows NSIS installer

Postby sgrogan » Wed Apr 13, 2016 8:14 pm

Next problem :(
Is there a trick to building the INSTALL project with VS2008?

The install directory doesn't seem to exist on my system, although the build log suggests otherwise.
BuildLog.htm.zip
fake zip
(152.66 KiB) Downloaded 110 times