The installer currently allows for three built-in rules when overwriting existing files. What if I want to develop a custom rule based on a string that exists inside the file rather than file attributes? How can I implement such a feature?

asked 22 Nov '11, 06:59

GigaG's gravatar image

GigaG
419911
accept rate: 0%


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

link

answered 22 Nov '11, 07:58

wojciechka's gravatar image

wojciechka ♦♦
7.8k61122
accept rate: 26%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×7
×4

Asked: 22 Nov '11, 06:59

Seen: 1,084 times

Last updated: 22 Nov '11, 07:58