Example Script |
Top Previous Next |
The following sample shows an example of a complex script for an imaginary application called MyApp that does the following:
•Setup global variables, retrieving the version number from the target application •Setup notification variables •Compile the Help file and Manual for the application, using Help and Manual and without applying a skin •Build the installers for the application along with its help and manual, using InnoSetup •Digitally sign the resulting installer •Zip the installer ready for distribution •Upload the installer to a web server •Check to see if there is a database update associated with the release •If there is, upload it •Rename the output directory ready for the next run, automatically incrementing the name if it already exists, e.g. if the folder MyApp 1234 already exists, the new folder would become MyApp1234a IMPORTANT: all of the information in this script is fictitious and intended only to give you an idea of how to construct a complex script that will perform multiple tasks. You may want different tasks, or a different order, but if you try to use any of the entries below as a template you will need to replace the information in the example with the relevant information suited to your own purposes.. Here is the script:
[Setup] ; Declare Variables and values that change frequently or are critical first, and consider declaring those in the Setup section even if they are ; specific to a particular section. That way you can simply make changes at the top of the script without having to go through ; the rest of it and risk messing up or missing one:
Var:Publisher=My Software Company Ltd Var:VersionTargetFile="C:\Programming\Source\MyApp\bin\Release\MyApp.exe" Var:Version=GetFileVersion,%%VersionTargetFile%% Var:FileNameVersion=GetFileNameVersion,%%VersionTargetFile%%
Var:Major=GetMajorFileVersion,%%VersionTargetFile%% Var:Minor=GetMinorFileVersion,%%VersionTargetFile%% Var:Build=GetBuildFileVersion,%%VersionTargetFile%% Var:Revision=GetRevisionFileVersion,%%VersionTargetFile%%
; Now declare other global variables here
Var:ApplicationRoot="C:\Programming\Source\MyApp" Var:BaseScriptRoot="C:\Programming\Source\MyApp\Distribution\Script\Base Scripts" Var:GenerateReport=true Var:IsccRoot="C:\Program Files (x86)\Inno Setup 6" Var:ReportFileName="%%TempFolder%%\My Application Release %%FileNameVersion%%.log" Var:ScriptRoot="C:\Programming\Source\MyAppAccounts\Distribution\Script" Var:SetupRoot="C:\Programming\Source\MyAppAccounts\Distribution\Setup" Var:SigningCertificate="C:\Programming\Source\Code Signing Certificate\MyApp Code Signing Certificate.pfx" Var:SignTool="C:\Programming\Source\Sign\signtool.exe" Var:SignToolParameters=$"sign /f \"%%SigningCertificate%%\" /p MyAppCertificate1 /t http://timestamp.digicert.com /fd SHA256" Var:TempFolder="%%ApplicationRoot%%\Temp" Var:UpdateScriptRoot="C:\Programming\Source\MyApp\UpdateScripts\Scripts"
[Notification]
; Turn off the standard failure action by setting the variable value to Continue Var:FailureAction=Continue
; Declare local variables here - only available in the current section Var:NotificationType=SMS Var:Notify=OnErrorAndSuccess Var:ReportFileName=%%ReportFileName%%\ Var:SmsApiMode=Live Var:SmsOriginator=MyAppAcc Var:SmsErrorMessage=Something went very wrong with the pipeline! Var:SmsToNumber=447905123456 Var:SmsPassword=password Var:SmsUsername=myusername Var:SmsSuccessMessage=The pipeline completed successfully!
[Compile MyApp Help and User Manual]
Var:HelpMan="C:\Program Files (x86)\EC Software\HelpAndManual8\HELPMAN.EXE" Var:HelpRoot="C:\Programming\Source\MyApp\Help"
Remark: Compile MyApp HTML Help Exec: "%%HelpMan%%","%%HelpRoot%%\MyApp\MyApp.hmxp /CHM=%%HelpRoot%%\MyApp.chm /I=CHM"
Remark: Compile MyApp PDF User Manual Exec: "%%HelpMan%%","%%HelpRoot%%\MyApp\MyApp.hmxp /PDF=%%HelpRoot%%\MyApp User Manual.pdf /I=PDF"
[InnoSetup - Build Installer]
Mod:AppVerName=,AppVerName=MyApp Accounts %%Version%%,/LineStartsWith /replacewholeline Mod:AppCopyright=,AppCopyright=MyApp Ltd %%Year%%,/LineStartsWith /replacewholeline Mod:VersionInfoVersion=,VersionInfoVersion=%%Version%%,/LineStartsWith /replacewholeline Mod:VersionInfoCopyright=,VersionInfoCopyright=MyApp Ltd %%Year%%,/LineStartsWith /replacewholeline
ModifyFile:"%%BaseScriptRoot%%\MyApp.iss","%%ScriptRoot%%\MyApp.iss"
Remark:BLANK-LINE Remark:Building MyApp Installer Exec:"%%IsccRoot%%\ISCC.exe","%%ScriptRoot%%\MyApp.iss"
[Sign Installer]
Remark:Signing My App Installer Exec:%%SignTool%%,%%SignToolParameters%%,"%%SetupRoot%%\MyApp\myappsetup.exe"
[Zip Installer]
Zip:"%%SetupRoot%%\MyApp\myappsetup.exe","%%SetupRoot%%\MyApp\MyApp %%FileNameVersion%%.zip"
; If there is a database update, zip it
If:FileExists:"%%UpdateScriptRoot%%\Database Update %%IncrementedFileNameVersion%%.sus",Zip:"%%UpdateScriptRoot%%\Database Update %%IncrementedFileNameVersion%%.sus","%%UpdateScriptRoot%%\Database Update %%IncrementedFileNameVersion%%.zip"
[Upload Files]
Var:Host=myserver.com Var:Password=mypassword Var:Port=22 Var:Protocol=SFTP Var:TargetFolder=/home/MyApp/www/downloads Var:UserName=MyApp
;Command Format: ;Command Name:File(s) to upload, separated by Pipe characters if there are multiple entries,Host,Password,Port,Protocol,TargetFolder,UserName,FtpUploadOptions FtpUpload:"%%SetupRoot%%\MyApp\MyApp %%FileNameVersion%%.zip",%%Host%%,%%Password%%,%%Port%%,%%Protocol%%,%%TargetFolder%%,%%UserName%%,None
; If there is a zipped database update, upload it If:FileExists:"%%UpdateScriptRoot%%\Database Update %%FileNameVersion%%.zip",FtpUpload:"%%UpdateScriptRoot%%\Database Update %%FileNameVersion%%.zip",%%Host%%,%%Password%%,%%Port%%,%%Protocol%%,%%TargetFolder%%,%%UserName%%,None
[Rename Output Directory]
Var:ProtectedRoot="C:\Programming\Source\MyApp\Distribution\Protected"
RenameDirectory:"%%ProtectedRoot%%\MyApp","MyApp %%Revision%%",IncrementAlpha
|