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

Comments

14 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.

    0
    Comment actions Permalink
  • 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

    0
    Comment actions Permalink
  • Avatar
    Lam

    Hi.

    I am trying to do something similar to this where I have an INI file section which point me to a custom name and version of the build for Window vs Linux. When I run the build, it doesn't matter the platform, I still get the version (the one in "window" platform). My "app_version" should be different on each platform. It's like it does not consider the "linux" platform at all.

    <preBuildActionList>
    <iniFileGet file="${build_project_directory}/Windows/Build_Tools/Window_Package_Config.ini" key="Package_Name" section="Window_Full_Package_Info" variable="app_name">
    <ruleList>
    <platformTest>
    <type>windows</type>
    </platformTest>
    </ruleList>
    </iniFileGet>
    <iniFileGet file="${build_project_directory}/Windows/Build_Tools/Window_Package_Config.ini" key="Package_Version" section="Window_Full_Package_Info" variable="app_version">
    <ruleList>
    <platformTest>
    <type>windows</type>
    </platformTest>
    </ruleList>
    </iniFileGet>
    <iniFileGet file="${build_project_directory}/Linux/Build_Tools/Linux_Package_Config.ini" key="Package_Name" section="Linux_Full_Package_Info" variable="app_name">
    <ruleList>
    <platformTest>
    <type>linux</type>
    </platformTest>
    </ruleList>
    </iniFileGet>
    <iniFileGet file="${build_project_directory}/Linux/Build_Tools/Linux_Package_Config.ini" key="Package_Version" section="Linux_Full_Package_Info" variable="app_version">
    <ruleList>
    <platformTest>
    <type>linux</type>
    </platformTest>
    </ruleList>
    </iniFileGet>
    </preBuildActionList>

    0
    Comment actions Permalink
  • Avatar
    michiel

    Hi Bui,

    In the <preBuildActionList> you should check for platform_name instead, which points to the target platform at build time. For example:

    <preBuildActionList>
     <iniFileGet file="${build_project_directory}/test.ini" key="Package_Name" section="Linux_Full_Package_Info" variable="app_name">
       <ruleList>
         <compareText text="${platform_name}" value="linux"/>
       </ruleList>
    </preBuildActionList>

    Would this work for you?

    Regards,

    Michiel

     

    0
    Comment actions Permalink
  • Avatar
    Lam

    Hi,

    That does works when I build it, but when I installed, the variable is mess up n my naming/version convention in the window registry. Not sure where I did wrong...I use "

    <preBuildActionList>
    <iniFileGet file="${build_project_directory}/test.ini" key="Package_Name" section="Window_Full_Package_Info" variable="app_name">
    <ruleList>
    <compareText text="${platform_name}" value="windows">
    <logic>equals</logic>
    </compareText>
    </ruleList>
    </iniFileGet>
    <iniFileGet file="${build_project_directory}/test.ini" key="Package_Version" section="Window_Full_Package_Info" variable="app_version">
    <ruleList>
    <compareText text="${platform_name}" value="windows">
    <logic>equals</logic>
    </compareText>
    </ruleList>
    </iniFileGet>
    </preBuildActionList>

    Product Details:

    Product Name = ${app_name}

    Version Number = ${app_version}

    Result:

    0
    Comment actions Permalink
  • Avatar
    Lam

    Below seem to works, but I want the full/file name of the project to be editable through a configuration file (such as INI) instead of inside the project XML file.

    <preBuildActionList>
    <actionGroup>
    <actionList>
    <setInstallerVariable name="project.fullName" value="My Project Name"/>
    <setInstallerVariable name="project.installerFilename" value="My Package Name.exe"/>
    </actionList>
    </actionGroup>
    </preBuildActionList>

    0
    Comment actions Permalink
  • Avatar
    michiel

    Hi Lam,
    An option would be to use an external script that first replaces the project name with the value in the ini file and then launches the installer. In Bash for example:

    #!/bin/bash



    projectName=$(awk -F "=" '/project_name/ {print $2}' project.ini
    
cat template_project.xml | sed -e 's/@@PROJECT_NAME@@/$projectName/g' > project.xml
    
/opt/installbuilder/bin build project.xml



     

    Would this work for you?


    Regards,
    Michiel

    0
    Comment actions Permalink
  • Avatar
    Paula

    Hi,

    I'm having similar issues where the project.fullName was not set properly in the welcome page.
    I didn't add custom-en.lng so i'm expecting the default Built-in Installer Text Strings below is used by the installer.

    ...
    Installer.Welcome.Title=Setup - %1$s
    Installer.Welcome.Text=Welcome to the %1$s Setup Wizard.
    ...

    It is expected that %1$s should have the same values, right?

    In the XML:
    Product Name is "Dummy Project Package"
    Product Filename is "DummyProjectPackage"

    In bash script I want to customize the project name to:
    $projectname="Dummy_Project_Package"
    bin/builder build $LinuxXML --setvars project.fullName=$projectname

    Welcome page shows:
    Setup - DummyProjectPackage
    Welcome to the Dummy_Project_Package Setup Wizard

    Not sure why it results to different values?

    0
    Comment actions Permalink
  • Avatar
    Lam

    Hi InstallBuilder Support,

    The renaming mechanism works in Windows, but we still see in the project name not what it supposed to be in Linux system. Looks like it showing the original "Product Filename" instead of the one we specifies when building an installer.

    0
    Comment actions Permalink
  • Avatar
    BitRock support

    Hi Paula,

    Please accept our apologies for the delay in our reply. We did not see your question until now. Could you try setting the project.fullName in the following way:

    ./ib/bin/builder build project.xml --setvars project.fullName="$projectname"

     

    0
    Comment actions Permalink
  • Avatar
    BitRock support

    Hi Jake,

    Can you give more details about how you are setting it in your project and on which moment it shows the original product filename? 

    0
    Comment actions Permalink
  • Avatar
    Paula

    Hi BitRock support,

    I've tried this but I still see the same issues wherein the Installer.Welcome.Title shows the original "Product Filename" from the project XML instead of the specified $projectname when building the installer.

    0
    Comment actions Permalink
  • Avatar
    michiel

    I've not been able to reproduce the issue. Could you try the following? 

    First create the following script:

    #!/bin/bash
    projectName="Dummy_Project_Package"
    INSTALLDIR/bin/builder build sample.xml --setvars project.fullName=$projectName

    Replacing INSTALLDIR with the InstallBuilder installation directory and using an empty new sample.xml as a project?

    And then run the script?

    Both Installer.Welcome.Title and Installer.Welcome.Text should be replaced with Dummy_Project_Package in the Welcome page. If this is not the case, could you run the installer with the --debugtrace and send it to support@bitrock.com?

     

     

     

    0
    Comment actions Permalink
  • Avatar
    Paula

    I've tried this but the Installer.Welcome.Title and Installer.Welcome.Text values were still not the same.

    Also the --debugtrace doesn't work with the sample XML. I've sent the support@bitrock.com the sample XML and sample bash script to reproduce in your end.



    0
    Comment actions Permalink

Please sign in to leave a comment.