Search code examples
jenkinsmsbuildnsis

using NSIS to install and run every time


Im doing a little research into installers, and right now at my company we are having some issues deploying from jenkins using click once. We have a test certificate(these programs are all internal) and for some reason are having some issues with the certifcate being incompatiable with certain msbuilds/.net frameworks. So im looking into alternatives.

But in that i want to keep the same architecture. How it works right now is someone clicks on a button in our task bar, clicks on the application they want, and then click once installs the updates(or installs) without further user input and starts the application. Ive heard a lot of good things about NSIS.

So far ive only seen generic application installers like you expect when you download anything from the internet. Could I do something like i described above using NSIS?


Solution

  • A very basic no interaction installer might look like this:

    Name foo
    OutFile foo_setup.exe
    AutoCloseWindow true
    RequestExecutionLevel user
    InstallDir "$LocalAppData\Programs\MyApp"
    
    Page InstFiles
    
    Section
    SetOutPath "$InstDir"
    WriteUninstaller "$InstDir\uninst.exe"
    ; TODO: Add registry entry for Add/Remove Programs
    File "MyApp.exe"
    File "Data.xml" ; Support files etc
    Exec '"$InstDir\MyApp.exe" -firstrun "c:\some path\file.ext"'
    SectionEnd
    
    Section Uninstall
    Delete "$InstDir\MyApp.exe"
    Delete "$InstDir\Data.xml"
    Delete "$InstDir\uninst.exe"
    RMDir "$InstDir"
    SectionEnd
    

    If you want to install for all users in %ProgramFiles% you can run into issues with Exec because the app can end up running as the wrong user if a non-administrator used some other account in the UAC dialog.