Friday, 11 November 2011

Windows Installer for NAnt

In the OpenPetra project, we completely depend on NAnt, which works out very well for us.
But we have had now several problems with permissions for executing nant on Windows, from the Program Files directory. Also the creation of the nant.bat was not trivial, and could cause problems with permissions.

The easy solution was to create a small InnoSetup Installer.
You can download it from our files section at SourceForge: http://sourceforge.net/projects/openpetraorg/files/openpetraorg/Tools/NAnt-Setup-0.91.exe/download

The script file for InnoSetup looks like this:

[Setup]
AppName=NAnt
AppVerName=NAnt 0.91
DefaultDirName={pf}\NAnt
DefaultGroupName=NAnt
LicenseFile=nant-0.91\COPYING.txt
OutputBaseFilename=NAnt-Setup-0.91
[Files]
Source: nant-0.91\*.*; DestDir: {app}; Flags: recursesubdirs createallsubdirs
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep=ssPostInstall then
  begin
    SaveStringToFile(ExpandConstant('{win}/nant.bat'), ExpandConstant('@"{app}\bin\NAnt.exe" %*'), False);
  end;
end;
If you have trouble with your old NAnt installation, you should delete the folder first from the Program Files, before you run the installer!