# ProjectPackager

projectPackager is a script and workflow to create installers that packages a TouchDesigner project with the necessary TouchDesigner program files into an distributable installer. For the enduser, the result will look like an installed application. 

TouchDesigner is "hidden" in the folder structure without any references in the Program entries, start menu or desktop. It should be noted that a install maker can choose to not install certain files that would be required for a fully functional TouchDesigner. Hence using TouchDesigner from the project's installation folder will not be the same as running a vanilla installed version.

> While you can fully customize the script, removing the dialog which displays Derivative's License is against Derivative's Terms and Conditions. When endusers install a project that runs with TouchDesigner, it needs to be made clear that the project has a license and the enduser also agrees to Deriative's License and Terms and Conditions.
> Further, it is important to note that endusers will have to install a TouchDesigner license key when running a project in TouchDesigner.

TouchDesigner uses [innoSetup](https://jrsoftware.org/isinfo.php) to build it's windows os installer.
> Inno Setup is a _free_ installer for Windows programs by Jordan Russell and Martijn Laan. First introduced in 1997, Inno Setup today rivals and even surpasses many commercial installers in feature set and stability.[^1]

# Prerequisits

> This workflow will only create an installer for the windows operating system.

- innoSetup

# Required Files
- **a TouchDesigner project** that is contained in a single folder strucutre. This means that any assets this project might use have to be located under the same root folder as the TouchDesigner project file. A creator should make sure that any references to external media and files is relative.
- **a TouchDesigner Installer file** which can be downloaded from [derivative](https://derivative.ca/download). Only Installers starting with 2022.xxxxx are supported.
- an icon file for the project
- a license file for your project.[^2]

> There are may different License types that can be choosen from. It is though important to make sure that the choosen license works in conjunction with Derivative's License.

# Limitations
The overall installer size cannot exceed **2.1 GB**.
# Instructions
## Preperations
1. Download InnoSetup from here: https://jrsoftware.org/isdl.php
2. Install InnoSetup
3. *(optional)* When using an IDE like VisualStudio, it might make sense to install the "Inno Setup" Extension.[^3] Furthermore InnoSetup and this installer script make use of Pascal Scripting (modern Delphi-like Pascal). Installing the Pascal Extension is recommended to ease development.[^4]
4. Clone this repository.[^5]
5. Make sure the project is contained in a single folder tree.

## Compiling the Installer
The script of interest is called *projectPackager.iss*. By default it is a fully functioning install builder which requires a number of arguments to be compiled:


> - **ProjectName**: (*required*) The name the project and the installer will have.
> - **ProjectVersion**: (*optional*, default: 1.0.0.1) A version number for this project.
> - **ProjectPublisher**: (*required*) The name of the publisher (you or your company).
> - **ProjectURL**: (*optional*, default: None) A URL where end-users might find information about the project.
> - **ProjectIcon**: (*optional*) The path to the icon file that will be associated with this project.
> - **ProjectLicense**: (*optional*, default: None) The path to a ```*.rtf``` file containing the license this project should be licensed under. If not specified, the license displayed > during the installation process will be the [unlicense](https://choosealicense.com/licenses/unlicense/). 
> - **ProjectFolder**: (*required*) The path to the project that will be packaged.
> - **ProjectFile**: (*required*) The path to the project's main ```*.toe``` file.
> - **StartWithPlayer**: (*optional*, default: 0) Ability to choose if the project should start with TouchPlayer (*default*) or TouchDesigner.
> - **TDInstallerLocation**: (*required*) The path to the TouchDesigner Installer that will be packaged with this project.
> - **TDSkipFiles**: (*optional*, default: None) Path to a text file containing a list of files from the TouchDesigner installation that should not be packaged with the project. See [#Decreasing Installersize]
> - **InstallerIcon**: (*optional*, default: an icon) Specify the path to a custom icon which will be that of the installer file.
> - **OutputName**: (*optional*, default: ProjectName) Specify the name of the installer file.
> - **CodeMeter**: (*optional*, default: 0) If set to true will install the codemeter runtime at the end of the installation process.
> - **Sign**: (*optional*, default: 0) If the machine has a code sign certificate installed, enaling this will attempt to sign the installer.


All of these arguments can be set via the projectPackager.ini file that is included with the repository.

Optionally, the arguments can be set via the commandline.

### Using the projectPackager.ini file:
In a Terminal navigate to the repository and run:

```
>ISCC.exe projectPackager.iss
```

### Using Commandline arguments:
Remove the projectPackager.ini file and in a Terminal navigate to the repository and run:
```
>ISCC.exe /dProjectName="My Project" /dProjectVersion="1.0.0.2" projectPackager.iss
```

> * Pay attention to how every argument needs to be prefaced by */d*
> * It should also be noted that entries in the .ini file and command line arguments can be mixed. The command line arguments will take precedence over ini file entries.

## Decreasing Installer size
The `TDSkipFiles` command line argument during compilation of the installer will skip certain files from being included in the final installer. Refer to the example [skipFiles.txt](skipFiles.txt) to see what files might not be necessary for your project.

## Creating a github workflow
This is work in progress.

## End User License Agreement
You and those to whom you distribute TouchDesigner with your project package are bound, upon installation, by the TouchDesigner End User License Agreement located here: https://derivative.ca/end-user-license-agreement-eula

[^1]: https://jrsoftware.org/isinfo.php
[^2]: https://choosealicense.com
[^3]: https://marketplace.visualstudio.com/items?itemName=idleberg.innosetup
[^4]: https://marketplace.visualstudio.com/items?itemName=alefragnani.pascal
[^5]: https://github.com