Search code examples
nsisngen

Invoke ngen from NSIS installer


I am using NSIS to deploy a .Net application. The installation/uninstallation process works fine, but I would like to add a final ngen step to improve startup performance.

Unfortunately, Google didn't reveal any relevant material. It's unlikely that noone has ever done this before - maybe someone here has some idea?

In the unlikely case that this is impossible to support without ugly hacks, I would be willing to use a different installer technology provided it can run on my Linux build server. (This rules out WiX, for example.)

Any ideas?


Solution

  • You could execute ngen in your last section using the built in Exec/ExecWait commands (Alternatively, use nsExec or one of the 3rd party exec plugins)

    ExecWait '"ngen.exe" install "c:\path\to\your\assembly" /silent'
    

    Note: this assumes that ngen is in the path or current directory which it probably is not on most systems, so either set the current directory with SetOutPath or use a full path to ngen

    You have to figure out the exact switches you need on your own, see MSDN for 2.0 and 1.x ngen documentation