Skip to content

Instantly share code, notes, and snippets.

@col000r
Last active August 29, 2015 13:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save col000r/9911434 to your computer and use it in GitHub Desktop.
Unity3D + Triton Ocean + Inno Setup = Installer

Inno Setup script for a Unity Project using Triton Ocean

This script creates an installer that puts everything Triton Ocean needs to function in the correct place and then installs the Visual C++ 2010 SP1 runtime libraries as well as the latest DirectX runtime libraries.

The script automatically checks if the correct version of the Visual C++ runtime is already installed and skips that step if it is (No thanks to me, I got the code from StackOverflow)

The DirectX runtime installer is always run. If you happen to know how to make a check and skip this step if it's not necessary, I'd love to know! (Especially since the DirectX web setup needs an online connection and installs their bing-bar bloatware on your PC unless you uncheck the box...)

Prerequisites

Get the Unicode version of the Inno Setup QuickStart Pack and install it.

Download the redistributable installers directly from Microsoft here and here and place them in the "Redistributables" folder (or change the script according to their location)

My workflow

  • Make a build in Unity, put the correct things in the correct places for Triton to function.
  • Run the Inno Setup New Script Wizard (File > New > New Script (Wizard) in Inno Script Studio) and go through all the steps (This tutorial might help - take special note of this quick tip - quote from the tutorial: "A quick note about the MyGame_Data folder. You can select it directly, then click edit and set the destination subfolder to “MyGame_Data”. This will create the proper subdirectory once the installation is done and you will not be including any unnecessary files." - If you just add the directories and don't to this step, their contents will be taken out of the directory and placed at app level, which is not at all what we want. Compare the result to my inno setup file if you're unsure you did it correctly. You should be able to fix it from there)
  • Open the resulting script and copy paste from the file below. (Add the two redistributable files to Files, make sure they are run during the installation in the Run section and finally add the entire Code section.
  • Project > Compile
  • You should now find your setup file in the Output folder! Install and test!
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "YOUR APP NAME"
#define MyAppVersion "1.0"
#define MyAppPublisher "YOUR COMPANY NAME"
#define MyAppURL "http://www.yourURL.com"
#define MyAppExeName "XYZ.exe"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{YOUR GUID GOES HERE!}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputBaseFilename=Setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
[Files]
Source: "C:\PROJECTS\builds\Redistributables\vcredist_x86.exe"; DestDir: {tmp}; Flags: deleteafterinstall
Source: "C:\PROJECTS\builds\Redistributables\dxwebsetup.exe"; DestDir: {tmp}; Flags: deleteafterinstall
Source: "C:\PROJECTS\builds\XYZ.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\PROJECTS\builds\XYZ_Data\*"; DestDir: "{app}\XYZ_Data"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\PROJECTS\builds\TritonDLL.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\PROJECTS\builds\TritonResources\*"; DestDir: "{app}\TritonResources"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
[Run]
; add the Parameters, WorkingDir and StatusMsg as you wish, just keep here
; the conditional installation Check
Filename: "{tmp}\vcredist_x86.exe"; Check: VCRedistNeedsInstall; StatusMsg: Installing Visual Studio 2010 C++ CRT Libraries...
Filename: "{tmp}\dxwebsetup.exe"; StatusMsg: Installing DirectX Runtime Libraries...
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Code]
#IFDEF UNICODE
#DEFINE AW "W"
#ELSE
#DEFINE AW "A"
#ENDIF
type
INSTALLSTATE = Longint;
const
INSTALLSTATE_INVALIDARG = -2; // An invalid parameter was passed to the function.
INSTALLSTATE_UNKNOWN = -1; // The product is neither advertised or installed.
INSTALLSTATE_ADVERTISED = 1; // The product is advertised but not installed.
INSTALLSTATE_ABSENT = 2; // The product is installed for a different user.
INSTALLSTATE_DEFAULT = 5; // The product is installed for the current user.
VC_2005_REDIST_X86 = '{A49F249F-0C91-497F-86DF-B2585E8E76B7}';
VC_2005_REDIST_X64 = '{6E8E85E8-CE4B-4FF5-91F7-04999C9FAE6A}';
VC_2005_REDIST_IA64 = '{03ED71EA-F531-4927-AABD-1C31BCE8E187}';
VC_2005_SP1_REDIST_X86 = '{7299052B-02A4-4627-81F2-1818DA5D550D}';
VC_2005_SP1_REDIST_X64 = '{071C9B48-7C32-4621-A0AC-3F809523288F}';
VC_2005_SP1_REDIST_IA64 = '{0F8FB34E-675E-42ED-850B-29D98C2ECE08}';
VC_2005_SP1_ATL_SEC_UPD_REDIST_X86 = '{837B34E3-7C30-493C-8F6A-2B0F04E2912C}';
VC_2005_SP1_ATL_SEC_UPD_REDIST_X64 = '{6CE5BAE9-D3CA-4B99-891A-1DC6C118A5FC}';
VC_2005_SP1_ATL_SEC_UPD_REDIST_IA64 = '{85025851-A784-46D8-950D-05CB3CA43A13}';
VC_2008_REDIST_X86 = '{FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}';
VC_2008_REDIST_X64 = '{350AA351-21FA-3270-8B7A-835434E766AD}';
VC_2008_REDIST_IA64 = '{2B547B43-DB50-3139-9EBE-37D419E0F5FA}';
VC_2008_SP1_REDIST_X86 = '{9A25302D-30C0-39D9-BD6F-21E6EC160475}';
VC_2008_SP1_REDIST_X64 = '{8220EEFE-38CD-377E-8595-13398D740ACE}';
VC_2008_SP1_REDIST_IA64 = '{5827ECE1-AEB0-328E-B813-6FC68622C1F9}';
VC_2008_SP1_ATL_SEC_UPD_REDIST_X86 = '{1F1C2DFC-2D24-3E06-BCB8-725134ADF989}';
VC_2008_SP1_ATL_SEC_UPD_REDIST_X64 = '{4B6C7001-C7D6-3710-913E-5BC23FCE91E6}';
VC_2008_SP1_ATL_SEC_UPD_REDIST_IA64 = '{977AD349-C2A8-39DD-9273-285C08987C7B}';
VC_2008_SP1_MFC_SEC_UPD_REDIST_X86 = '{9BE518E6-ECC6-35A9-88E4-87755C07200F}';
VC_2008_SP1_MFC_SEC_UPD_REDIST_X64 = '{5FCE6D76-F5DC-37AB-B2B8-22AB8CEDB1D4}';
VC_2008_SP1_MFC_SEC_UPD_REDIST_IA64 = '{515643D1-4E9E-342F-A75A-D1F16448DC04}';
VC_2010_REDIST_X86 = '{196BB40D-1578-3D01-B289-BEFC77A11A1E}';
VC_2010_REDIST_X64 = '{DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}';
VC_2010_REDIST_IA64 = '{C1A35166-4301-38E9-BA67-02823AD72A1B}';
VC_2010_SP1_REDIST_X86 = '{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}';
VC_2010_SP1_REDIST_X64 = '{1D8E6291-B0D5-35EC-8441-6616F567A0F7}';
VC_2010_SP1_REDIST_IA64 = '{88C73C1C-2DE5-3B01-AFB8-B46EF4AB41CD}';
function MsiQueryProductState(szProduct: string): INSTALLSTATE;
external 'MsiQueryProductState{#AW}@msi.dll stdcall';
function VCVersionInstalled(const ProductID: string): Boolean;
begin
Result := MsiQueryProductState(ProductID) = INSTALLSTATE_DEFAULT;
end;
function VCRedistNeedsInstall: Boolean;
begin
// here the Result must be True when you need to install your VCRedist
// or False when you don't need to, so now it's upon you how you build
// this statement, the following won't install your VC redist only when
// the Visual C++ 2010 Redist (x86) and Visual C++ 2010 SP1 Redist(x86)
// are installed for the current user
Result := not VCVersionInstalled(VC_2010_SP1_REDIST_X86);
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment