Joe Cincotta: Thoughts and such…

Icon

Nerdism for the masses.

PreNIS 1.0 – The NSIS PreProcessor for .Net

Download PreNIS 1.0 Beta

The PreProcessor for the NullSoft Installer System.

1. Why make a Pre-Processor for NSIS?

We at Pixolüt ONLY use NSIS for deployments. We have .Net user applications and also
server deployments which all use NSI scripts.

The only problem with using an external installer system, especially a scipt based one is that its painful to manage the sync between the project file and the installer script to ensure that only required DLLs and content files are included. Also, every time a new DLL, file or folder is added to the project, the install script needs to be updated.

What about version information – that needs to come from somewhere too!

Wouldn’t it be great to be able to use the .Net project file to dynamically create the NSI file whilst having all the power and features of NSIS? Well, with PreNIS you can. PreNIS provides a simple set of macro tags which will expand out and repeat for all folders or files specified and create a new NSI file which contains all correct files in the project.

2. Usage

prenis.exe “-source=c:\my project\installer\install.nsi” -target=c:\output.nsi

-source
source (input) nsi file

-target
target (output) nsi file

-help
shows a simple help text

To use quotes around a filename, make sure you use quotes around the argument too
“-source=bah bah” is correct
-source=”bah bah” is not correct

3. Script Documentation
All commands follow the format:
##command##
where they start and end with ## to specify the preprocessor arguments.
Arguments are sperated by the ; character and use argument=value format.
Arguments can be split over multiple lines

##command;
 arg=value;
 arg2=value##

The Import command


##import;
 project=filename of project file;
 folder=path to project files;
 config=Debug##

The folder argument is optional and not used if the project file is in the base folder of the project file.

Macro commands
In between a macro, you can put any NSI commands and use the macro-variables.
The macro-variables work as follows:

 %%absfilename%%  insert the absolute filename ie: c:projectmyfile.txt 

 %%abspath%%insert the absolute path ie: c:project %%outpath%%insert the relative path ie: project %%filename%%insert the filename only ie: myfile.txt 

 %%relfilename%%insert the relative path and filename ie: projectmyfile.txt which is equivalent to %%outpath%%%%filename%%

macro.dll will insert all DLLs for the specified assembly. Ensure all dependant projects are also imported!


##macro.dll;assembly=assembly name##
 %%absfilename%%
 %%abspath%%
 %%outpath%%
 %%filename%%
 %%relfilename%%
##macro.end##

macro.pdb will insert all PDB files for the specified assembly. Ensure all dependant projects are also imported!

##macro.pdb;assembly=assembly name##
 %%absfilename%%
 %%abspath%%
 %%outpath%%
 %%filename%%
 %%relfilename%%
##macro.end##

macro.contentfolders will iterate through all folders for the specified project.
You can insert the macro.content macro inside a macro.contentfolders macro to expand out for each content file in each directory. the %%filename%% and %%abspath%% variables will act strange inside the contentfolders macro since they specify folders not files.

##macro.contentfolders;assembly=assembly name##
 %%absfilename%%
 %%abspath%%
 %%outpath%%
 %%filename%%
 %%relfilename%%
 ##macro.content##
  %%absfilename%%
  %%abspath%%
  %%outpath%%
  %%filename%%
  %%relfilename%%
 ##macro.end##
##macro.end##

macro.content will iterate through all files in the project if not used inside a contentfolders macro

##macro.content;assembly=assembly name##
 %%absfilename%%
 %%abspath%%
 %%outpath%%
 %%filename%%
 %%relfilename%%
##macro.end##

You can exclude or include specific files using the exclude or include commands inside a macro. The names allow wildcards either *name, name* or *name* to specifiy part of a filename. You can only use exclude or include exclusively, since by using the include command will automatically EXCLUDE ALL FILES except the files included. The Exclude command with INCLUDE ALL FILES except the ones excluded by the exclude commands.

You can have multiple of the same kind inside a single macro.


##exclude;filename=*config*##
##include;filename=config*##

The version command will take the version number from the assemblyinfo.cs (assemblyinfo.vb) for the specified assembly. The assembly must be imported first.

##version;assembly=assembly name;delimiter=.##

Advertisement

Filed under: Open Source, PreNIS

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.