Can I customize a rule for overwriting existing files?

Comments

1 comment

  • Avatar
    wojciechka

    It is not possible to create custom rules for overwriting existing files. However, it is possible to use <ruleList> for a <folder> to check if a certain set of files should be unpacked.

    For example the following can be used to compare version of embedded folder and one installed in the specified folder:

      <component>
        <!-- ... -->
        <folderList>
          <folder>
            <description>Program Files</description>
            <destination>${installdir}</destination>
            <name>programfiles</name>
            <platforms>all</platforms>
    
            <!-- store installed version - only executed if folder was installed -->
            <actionList>
              <iniFileSet>
                <file>${installdir}/versions.ini</file>
                <key>version_programfiles</key>
                <section>Versions</section>
                <value>${project.version}</value>
              </iniFileSet>
            </actionList>
    
            <ruleList>
              <!-- only install if project.version is newer than installed programfiles folder -->
              <compareVersions>
                <logic>greater</logic>
                <version1>${project.version}</version1>
                <version2>${version_programfiles}</version2>
              </compareVersions>
            </ruleList>
            <!-- ... -->
        </folderList>
        <readyToInstallActionList>
          <!-- default version to compare to -->
          <setInstallerVariable>
            <name>version_programfiles</name>
            <value>0.0</value>
          </setInstallerVariable>
          <!-- read version if file exists -->
          <iniFileGet>
            <file>${installdir}/versions.ini</file>
            <key>programfiles</key>
            <section>Versions</section>
            <variable>version_programfiles</variable>
            <ruleList>
              <fileExists>
                <path>${installdir}/versions.ini</path>
              </fileExists>
            </ruleList>
          </iniFileGet>
        </readyToInstallActionList>
      </component>
    

    This can be used to check versions for multiple folders - simply by adding a get/set action for INI file and by adding a check in <ruleList>.

Please sign in to leave a comment.