From Source Repo to Installer in One Script

Leoreth

Blue Period
Moderator
Joined
Aug 23, 2009
Messages
37,060
Location
東京藝術大学
1. Introduction

If you're like me, your mod project has grown over the years, and you've started to leverage all sorts of tools to create a better mod and to help your development process.

For Dawn of Civilization, this includes:
- hosting the mod in a Git repo
- offering additional optional modules, themselves hosted as Git repos
- compiling art as FPKs to save space and speed up the mod
- offering an install wizard to help people install the mod

If you're again like me, you're too lazy to take all the steps required to create a release for your mod under these circumstances. For my setup, this requires:
- exporting all Git repos to get rid of the internal Git info (saving space)
- copying the art somewhere else and run PakBuild (with its atrocious UI) to create an FPK file (while keeping movies separate because they don't work from FPK)
- run the compiler to create two install wizards (one with and one without modules)

These steps include creating a ton of intermediate files that need to be cleaned up afterwards. In short, so much work that I avoid it when I can, and release less than I should. The large spans of time between releases also mean that I forget some steps or make mistakes.

So I decided to do it right once and automate the entire process with a Powershell script. This is me sharing this process so you can adapt it for your project.

2. Assumptions

I'm quickly establishing how my mod is set up. The script is based around that, and if your project is different you have to adapt it accordingly. I did not write it to be universally applicable (and some parts of it are hacked in a rather ad hoc fashion), but I think I have solved the hardest problems you might encounter already. This setup includes:
- a main mod repository in Git ("RFC Dawn of Civilization")
- optional mod components, each in an additional Git repository (e.g. "DoC Varietas Delectat")
- the main mod contains Assets/Art as bare files to be edited in modding, these are supposed to be packaged as FPK before release (except movies)
- I have setup scripts for Inno Setup to create two install wizards for the mod

3. Requirements

The script itself requires Windows Powershell, which is included from Windows 7 onwards. If you have never run a Powershell script, you need to enable their execution first.

See here on how to do it. Basically, you open Powershell as administrator (you can find it in the Accessories folder) and type "Set-ExecutionPolicy Unrestricted" and press enter.

Spoiler What does this imply? :
Powershell scripts are disabled by default to protect your system against accidental execution of potentially harmful scripts (e.g. in email attachments). Be aware that by changing this setting you are removing this additional layer of security.


If you decide that you also want to create an install wizard using Inno Setup, you need to install it first. The download is here. But you can also just change the script to say package your mod into a ZIP or RAR instead.

4. Running the Script

You can download the script and the additional required resources HERE. After the download is complete, unpack them into your Mods/ folder (which of course also contains your mod). This should create the Release.ps1 script and a Release/ folder containing some other stuff.

You can run the script by either right-clicking it and select "Execute with Powershell" (might be slightly different, sorry my OS is in German). Alternatively, open Powershell and navigate to the Mods/ folder, then type '& "./Release.ps1"' (without single quotes) and press enter. The latter option has the advantage that the window will not immediately close on completion and you can see the output in case anything goes wrong. Depending on the size of your project and if additional components exist, this might take some time, but the script is doing all the work for you; just let it run in the background and do something else (although I advise against tampering with the Mods folder in the meantime).

As I said before, the script was quickly hacked together for my own purposes, and will probably only work if executed from that folder.

However, without some initial adjustments it will not work for you at all. The beginning of the script defines some variables that need to reflect your mod and its setup (I have obscured my file paths here). I have added some comments that hopefully explain the purpose of all variables sufficiently, as well as the purpose of some blocks of code.

The script also comes with the Inno Setup scripts I'm using. They're mostly to serve as an example/template of what you can do, and also need to reflect how your mod is set up (again, I have obscured my paths). If you don't have optional modules, the DoC Core script is a good place to start. I hope this helps familiarizing yourself with Inno Setup so you don't have as steep a learning curve as I did.

5. FAQ and Troubleshooting

I'm leaving this section to edit in answers to questions that may arise in this thread.

I hope I have explained everything sufficiently so that modders with sufficient experience can take it from there, but I'm willing to help customizing it to your project if you get stuck. I'm just as new to this.

6. Acknowledgements

Besides Inno Setup, the script also relies on the Autopak tool by TC01, which I have taken the liberty to repackage into this utility for simplicity. Full credits for that of course goes to them.

Download Link
One more time so you don't have to dig it up from the wall of text above :)

Script away, and enjoy the time saved!
 
If you're again like me, you're too lazy to take all the steps required to create a release for your mod under these circumstances.

Nice work! I may look into this for Final Frontier Plus for precisely this reason; I too feel demotivated to work on and especially release FF+ due to all the manual steps required to do so. I also use Inno Setup to generate my installers and git for version control (as you know from my recent tutorial :) ), so hopefully it should be pretty easy to apply this.

Also glad to see Autopak was helpful!
 
Yeah! I've been using Autpak for a while already and it helped shave off time (and frustration) dealing with PakBuild. In fact, it helped inspire me to go beyond that and create this script. So did your build server tutorial by the way.

In the long term, I'd even like to combine the two so I don't even have to push the button anymore. But that's for another time :)

Please let me know if I forgot to cover anything in the guide once you try it.
 
Top Bottom