Is there any way to access the list of files packed in the installer? I would like to iterate over this list. For each file, all I need is the name of the file and its target location.

Better still, can this be done for specific components and/or folders via their name attributes?

The reason I'd like to be able to do this is that in my update installer, a subset of the files have modified file names (because some filenames contain the version information). For these, I would like to be able to handle the removal of older versions without necessarily needing to know the exact names.

For example, if I'm installing

library-A_v1-2.dll
library-X_v1-2.dll

I'd like to clean up other instances of

library-A_v*.dll
library-X_v*.dll

If such enumeration of the packed files is not possible, is there an alternative approach I should consider? (I do not wish to have to run the uninstaller.)

Likewise, are there mechanisms for getting the name of any existing uninstaller and/or iterating over the files referenced in the uninstaller?

Alternatively, is there a mechanism for supplying a wildcarded name for replacing files?

For updates, there is an <overwritePolicy/> that can be used to control the replacement of files who's name remains the same.

It there a way to express something like this:

<distributionFile>
  <origin>${myOrigin}/lib-A_v${myVersion}.dll</origin>
  <replaces>lib-A_v*.dll</replaces>
  <replacePolicy>onlyIfNewer</replacePolicy>
</distributionFile>

or better still, some sort of regex-based replacement rule:

<distributionFile>
  <origin>${myOrigin}/lib-A_v${myVersion}.dll</origin>
  <replacePattern>^lib-A_v(.*).dll$</replaces>
  <substitution>\\1<substitution>
  <variable>temp<variable>
  <replaceRuleList>
    <compareVersions>
      <logic>greater</logic>
      <version1>${myVersion}</version1>
      <version2>${temp}</version2>
    </compareVersions>
  </replaceRuleList>
</distributionFile>

Thanks.

asked 20 Jan '12, 05:33

Rhubbarb's gravatar image

Rhubbarb
166610
accept rate: 0%

Another thought: the <overridePolicy/> (or <replacePolicy/>) options could include "onlyIfLaterVersion".

(20 Jan '12, 09:31) Rhubbarb

It is not possible to check packed files at runtime. Regarding cleaning old files, an possible solution would be to organize the files to upgrade into component and include there the cleaning:

<component>
   <name>libA</name>
   <folderList>
      <folder>
         <name>libACleaning</name>
         <actionList>
            <deleteFile path="${installer}/libs/lib-A_v*.dll"/>
         </actionList>
     </folder>
     <folder>
         <name>libA</name>
         <destination>${installdir}/libs</destination>
         <distributionFileList>
            <distributionFile>
               <origin>${myOrigin}/lib-A_v${myVersion}.dll</origin> 
            </distributionFile>
         </distributionFileList>
     </folder>
  </folderList>
</component>

Also, adding checking for a version in the <overridePolicy/> could be very complex as there is not a standard way. For example, for a Windows binary it may be possible to check the resources to check the version but it would not work in other platforms.

Another approach you could follow is to write a file with the current installed version and also store the current packed version in a variable. Then at runtime, if the packed version is greater, delete all the files, and if not, deselect the component.

link

answered 23 Jan '12, 09:59

juanjo's gravatar image

juanjo ♦♦
5.8k413
accept rate: 23%

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:

×20
×3
×2
×2

Asked: 20 Jan '12, 05:33

Seen: 1,516 times

Last updated: 23 Jan '12, 09:59