Pre- and Post-Build Scripts

EBuild projects may specify custom shell scripts to run before the main build process for the project starts, or after it (successfully) finishes. These scripts can be provided in a <PreBuild> or <PostBuild> element, respectively, on the top level of the project XML.

For backward compatibility with MSBuild, the <PreBuildEvent> or <PostBuildEvent> element names may be used instead.

Since Elements projects can be built on different platforms, and each platform has a different shell environment, separate <PreBuild> or <PostBuild> tags can be provided, each specifying a platform or – on Windows – a shell to run in (Cmd vs PowerShell).

EBuild will pick the best-suited script for the current platform, or the script that has no platform marker:

  <PreBuild Platform="macOS">
    ls -la
  </PreBuild>
  <PreBuild Platform="Cmd">
    dir
  </PreBuild>

Valid values for the "Platform" attribute are:

OS Values Comment
Windows Windows, Cmd, PowerShell Runs cmd.exe, except for PowerShell
macOS Mac, macOS, sh Always runs /bin/sh
Linux Linux, sh Always runs /bin/sh

The script will run with the project folder (i.e. the folder containing the .elements file) as the current working directory.

Variables

Any settings known to the project can be used in the script, using the $(SettingName) syntax. Literal occurences of $( can be escaped using a second dollar sign: $$(.

  <PreBuild>
    echo "$(BinaryName)"
  </PreBuild>