VMware Cloud Community
SebastianB1
Contributor
Contributor
Jump to solution

Update distribution file if it's newer, but using different names - thus without overwritePolicy

Hi there, I didn't find an answer to this question in the docs.

I know we can set 'project.overwritePolicy' to "onlyIfNewer", to avoid overwriting a distribution file with a more dated version of it.

But that assumes that the destination file has the same name, but different timestamp. Right?

What happens if instead of overwriting it,  the newer destination file changed its name ? e.g. it has a version number in its file name 

In my case, we make different installers for different products that goes inside a common folder, and there's a unique Activation executable for all the products.

Each installer drops the Activation executable to the common folder, and in case the installer is more dated it installs the product but doesn't overwrite the Activation executable. (For this purpose 'project.overwritePolicy' to "onlyIfNewer" just works OK)

But now the Activation executable needs to have a version number in its name. In this scenario, instead of overwriting a file we need to remove the older one and drop the new one. 

For example.

  • 1) There's a latest Activation2020.exe already in the common installation folder.
    • If you install an older product how to avoid dropping an Activation2019.exe file ?
  • 2) There's an older Activation2019.exe already in the common installation folder
    • If you install a newer product how to delete only Activation2019.exe and dropping Activation2020.exe ?

Is this possible ? There is some example on how to achieve this using InstallBuilder ?

Thank you in advance for any help and paying attention to this problem,

Sebastian

 

0 Kudos
1 Solution

Accepted Solutions
SebastianB1
Contributor
Contributor
Jump to solution

Thank you for your help,

We have N independent individual installers that we release on different dates.

And we have 1 single common file Activation.exe for all the N products, which comes with the individual installers, which after installing all the files of the product it just drop the file Activation.exe into the common folder.

Right now we use "overwritePolicy.onlyIfNewer" for that single file, so if costumer installs an old product, it keeps the Activation.exe up-to-date. It's working OK.

Notice the rest of the files of the individual installers use the default overwritePolicy.Always.

But now we need to include version number at the fileName level for the Activation file, e.g. Activation.2020.01exe , Activation.2020.02.exe , etc

How would you face that situation in the individual installers?

'overwritePolicy.onlyIfNewer' assumes the destination file have the same name ("Activation.exe"). which is not the case anymore here, if the names include version numbers. Right ?

I would like to keep only the latest Activation.XXXX.YY.exe installed on the common folder and clean up the older ones, even when installing a more dated product.

Is that possible?

Thank you again for you dedication !

 

Sebastian

 

View solution in original post

0 Kudos
3 Replies
gongomgra
VMware Employee
VMware Employee
Jump to solution

Hi @SebastianB1,

Can you give us more information about your specific scenario? Depending on how many files you expect to update from one version to the next one you could use the update installer or a regular installer acting like an update installer.

Please find below an example of what I mean here:

  • Updating a small list of versioned files: you can keep the list of files to be updated into the update installer and replace them according to your logic (implementing it into a forEach instruction for example). The rest of files would be replaced or not according to the project.overwritePolicy as of now.
  • Updating all or almost all of the files: in that case, we recommend you to create a regular installer and modify it to run like an upgrade one. It will deploy all the new files matching your criteria, and you will need to implement a delete action for those files not matching.

You can get more information about this in our docs in the next link

https://clients.bitrock.com/installbuilder/docs/installbuilder-userguide.html#_using_normal_mode_whe...

SebastianB1
Contributor
Contributor
Jump to solution

Thank you for your help,

We have N independent individual installers that we release on different dates.

And we have 1 single common file Activation.exe for all the N products, which comes with the individual installers, which after installing all the files of the product it just drop the file Activation.exe into the common folder.

Right now we use "overwritePolicy.onlyIfNewer" for that single file, so if costumer installs an old product, it keeps the Activation.exe up-to-date. It's working OK.

Notice the rest of the files of the individual installers use the default overwritePolicy.Always.

But now we need to include version number at the fileName level for the Activation file, e.g. Activation.2020.01exe , Activation.2020.02.exe , etc

How would you face that situation in the individual installers?

'overwritePolicy.onlyIfNewer' assumes the destination file have the same name ("Activation.exe"). which is not the case anymore here, if the names include version numbers. Right ?

I would like to keep only the latest Activation.XXXX.YY.exe installed on the common folder and clean up the older ones, even when installing a more dated product.

Is that possible?

Thank you again for you dedication !

 

Sebastian

 

0 Kudos
gongomgra
VMware Employee
VMware Employee
Jump to solution

Hi,

I think you can look for the existing Activation.{version}.exe file and extract it

<preInstallationActionList>
<findFile>
<baseDirectory>${installdir}</baseDirectory>
<pattern>Activation.*.exe</pattern>
<variable>installedFile</variable>
</findFile>
<setInstallerVariableFromRegEx>
<pattern>^.*Activation.([0-9]{4}.[0-9]+).exe</pattern>
<substitution>\1</substitution>
<name>installedFileVersion</name>
<text>${installedFile}</text>
</setInstallerVariableFromRegEx>
</preInstallationActionList>

 
And then compare this version with the one from the file you are going to deploy. You can do it in the actionList of the folder that unpacks the Activation.{version}.exe file: 

<actionList>
<if>
<conditionRuleList>
<compareVersions>
<version1>${installedFileVersion}</version1>
<logic>less</logic>
<version2>${project.version}</version2>
</compareVersions>
</conditionRuleList>
<actionList>
<deleteFile>
<path>${installedFile}</path>
</deleteFile>
</actionList>
<elseActionList>
<deleteFile>
<path>${installdir}/Activation.${project.version}.exe</path>
</deleteFile>
</elseActionList>
</if>
</actionList>

Hope it helps,
Gonzalo

0 Kudos