How to set product name and version dynamically at build time ?

Comments

2 comments

  • Avatar
    juanjo

    You could either read the information from the properties file in the <preBuildActionList>:

    <preBuildActionList>
        <propertiesFileGet>
            <file>${build_project_directory}\\data.properties</file>
            <key>version</key>
            <variable>project.version</variable>
        </propertiesFileGet>
        <propertiesFileGet>
            <file>${build_project_directory}\\data.properties</file>
            <key>full_name</key>
            <variable>project.fullName</variable>
        </propertiesFileGet>
        <propertiesFileGet>
            <file>${build_project_directory}\\data.properties</file>
            <key>short_name</key>
            <variable>project.shortName</variable>
        </propertiesFileGet>
    </preBuildActionList>
    

    Or configure it through command line when building:

    builder build project.xml --setvars project.version=1.8 project.fullName="Product B" project.shortName=productb
    

    You can find additional information here.

  • Avatar
    wojciechka

    You can read it inside <preBuildActionList> actions. You will also need to create a hidden parameter so that this information is stored in installer as well.

    For example in your case the following will read version.ini file from same directory where project XML file is located and read version key in [info] section:

    
     <project>
      <version>${app_version}</version>
      ...
      <preBuildActionList>
       <iniFileGet file="${build_project_directory}/version.ini" key="version" section="info" variable="app_version" />
      <preBuildActionList>
      ...
      <parameters>
       <stringParameter name="app_version" ask="0" />
      </parameters>
     </project>
    

    The ${app_version} variable will contain version at build and installation time. You can use it for other purposes.

    Another approach is to use --setvars parameter when building to specify variables that can then be used in the fields - by removing the <iniFileGet> action and doing:

    
    $ bin/builder build project.xml linux --setvars app_version=1.1
    

    More complex examples of doing custom builds and custom build targets are described in our documentation: Creating Custom Builds

Please sign in to leave a comment.