LinuxCommandLibrary

makensis

Create Windows installers using NSIS scripts

TLDR

Compile a NSIS script

$ makensis [path/to/file.nsi]
copy

Compile a NSIS script in strict mode (treat warnings as errors)
$ makensis -WX [path/to/file.nsi]
copy

Display help for a specific command
$ makensis -CMDHELP [command]
copy

SYNOPSIS

makensis [options] <script.nsi>

PARAMETERS

-D<name>[=<value>]
    Defines a preprocessor symbol. This allows for conditional compilation within the NSIS script, enabling features or configuration based on build parameters. For example, -DVERSION=1.0.

-X<command>
    Executes an NSIS command during compilation. This can be used to override directives in the script or inject specific commands at compile time, such as setting the output file: -X"OutFile setup.exe".

-V[0-4]
    Sets the verbosity level of the compiler output.
0: Silent (only errors).
1: Default.
2: Detailed (show all commands).
3: Debug (show all commands and macro expansions).
4: Debug with stack.

-WX
    Treats all compiler warnings as errors, causing the compilation to fail if any warnings are generated. This promotes stricter code quality in NSIS scripts.

-NOCONFIG
    Prevents makensis from reading the default nsis.ini configuration file. This ensures a clean compilation environment, ignoring any user-specific compiler settings.

-HDRINFO
    Displays information about the NSIS header (e.g., compressed size, uncompressed size). Useful for optimizing installer size.

-VERSION
    Displays the version information of the makensis compiler.

-LICENSE
    Displays the license information for NSIS.

DESCRIPTION

The makensis command is the compiler for the Nullsoft Scriptable Install System (NSIS), a powerful, script-driven installer creation tool for Microsoft Windows. It takes an NSIS script file (typically with a .nsi extension) as input and compiles it into a compact, self-contained Windows executable (.exe) installer. NSIS is known for its small overhead, flexible scripting language, and ability to create custom installers for software distribution. makensis enables developers on Linux (or macOS) to build Windows installers without needing a Windows environment, making it a valuable tool in cross-platform development and CI/CD pipelines.

CAVEATS

While makensis runs on Linux, the installers it produces are native Windows executables (.exe) and will not run directly on Linux without compatibility layers like Wine.
The command relies entirely on the provided NSIS script (.nsi file) for its instructions, meaning that creating an installer requires prior knowledge and authoring of the NSIS scripting language.

NSIS SCRIPTING LANGUAGE

NSIS uses a simple, yet powerful, scripting language that allows for complex installer logic, including file operations, registry modifications, shortcut creation, custom pages, and more. It supports variables, conditional statements, and functions, making it highly customizable.

CROSS-PLATFORM DEVELOPMENT

makensis is frequently used in continuous integration and continuous delivery (CI/CD) pipelines running on Linux-based servers. This allows developers to automatically build Windows installers for their applications as part of their automated build process, streamlining software releases.

HISTORY

NSIS was originally developed by Nullsoft, the creators of Winamp and Gnutella, in the early 2000s as an internal tool for their software. It was later released as open-source software under the zlib license, allowing it to gain widespread adoption and be actively maintained by a community of developers. The makensis compiler became a critical component in enabling cross-platform development workflows, especially for projects targeting Windows from non-Windows operating systems.

Copied to clipboard