Customizing Protobuild

You can customize Protobuild’s project generation by overriding the project generation templates that it uses.

Warning

Customizing the project generation templates is a very advanced feature of Protobuild. It is highly recommended that you’re well versed in creating Protobuild projects before customizing the project templates.

Specifying additional transforms

You can specify additional XSLT transforms to take place without overriding the whole project generation template. This can be used if you need to support additional steps in your build process.

To specify additional XSLT transforms during project generation, create an XSLT file at Build\AdditionalProjectTransforms.xslt. An example of this file’s contents is shown below (this example allows projects to have protocol buffers precompiled with protobuf-net).

<xsl:if test="/Input/Properties/PrecompileProtobuf = 'True'">
  <Target Name="AfterBuild">
    <Exec>
      <xsl:attribute name="WorkingDirectory">
        <xsl:value-of select="/Input/Generation/RootPath" />
      </xsl:attribute>
      <xsl:attribute name="Command">
        <xsl:if test="/Input/Generation/Platform = 'Linux' or /Input/Generation/Platform = 'MacOS' or /Input/Generation/Platform = 'iOS'">
          <xsl:text>mono </xsl:text>
          <xsl:text>Protogame/ThirdParty/protobuf-precompile/precompile.exe </xsl:text>
        </xsl:if>
        <xsl:if test="/Input/Generation/Platform = 'Windows' or /Input/Generation/Platform = 'Android'">
          <xsl:text>Protogame\ThirdParty\protobuf-precompile\precompile.exe </xsl:text>
        </xsl:if>
        <xsl:value-of select="/Input/Properties/PrecompileProtobufInputPath" />
        <xsl:text> -o:</xsl:text>
        <xsl:value-of select="/Input/Properties/PrecompileProtobufOutputPath" />
        <xsl:text> -t:</xsl:text>
        <xsl:value-of select="/Input/Properties/PrecompileProtobufSerializerName" />
        <xsl:text> -access:Public</xsl:text>
        <xsl:if test="/Input/Generation/Platform = 'Linux'">
          <xsl:text> -f:/usr/lib/mono/4.0/</xsl:text>
        </xsl:if>
        <xsl:if test="/Input/Generation/Platform = 'MacOS' or /Input/Generation/Platform = 'iOS'">
          <xsl:text> -f:/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.0/</xsl:text>
        </xsl:if>
        <xsl:if test="/Input/Generation/Platform = 'Android'">
          <xsl:text> -f:MonoAndroid\v1.0</xsl:text>
        </xsl:if>
      </xsl:attribute>
    </Exec>
  </Target>
</xsl:if>

This file is copied as-is into the project generation templates before they are used to generate the projects.

Tip

For more information about what is supported inside additional project transforms, extract the full templates as described below. The additional project transforms document has access to all of the functionality that the full generation templates do.

Extracting the XSLT templates

You can instruct Protobuild to extract the templates by running:

$ Protobuild.exe --extract-xslt

This will place the extracted templates under the Build\. When the templates are files in this location, they are used instead of the versions embedded into the Protobuild executable.

Modifying Protobuild

If you need additional functionality within the Protobuild executable, you can build your own version of Protobuild and ship it within your repository.

You can build a modified version of Protobuild by following the instructions in the FAQ: How do I build Protobuild itself?