How to set rule for overwriting existing files and folders

Comments

3 comments

  • Avatar
    alejandror

    You would need to exclude packing the "config" folder from the main <folder> setting <excludeFiles> in the <distributionDirectory>, and create a new one that just pack the "config" folder.

    Then you could follow this approach to change the overwrite policy for this single folder.

  • Avatar
    John123

    Hi Jesus

    what I am doing wrong here. it's not working for me.

    <folderList>
        <folder> 
          <description>Program Files</description>
          <destination>${installdir}</destination>
            <name>programfiles</name>
            <platforms>all</platforms>
            <distributionFileList>
             <distributionDirectory allowWildcards="1">
            <origin>D:/InstallBuilder/SampleProject</origin>                               <excludeFiles>D:/InstallBuilder/SampleProject/config/configure.properties</excludeFiles>
        </distributionDirectory>
        </distributionFileList>
       </folder>
    
       <folder>
         <description>Program Files</description>
          <destination>${installdir}</destination>
          <name>programfiles</name>
          <platforms>all</platforms>
          <distributionFileList>
          <distributionFile>
             <origin>D:/InstallBuilder/SampleProject/config/configure.properties</origin>
         </distributionFile>
         </distributionFileList>
        <ruleEvaluationLogic>and</ruleEvaluationLogic>
        <ruleList>
           <compareText text="${project.installationType}" logic="does_not_equal" value="upgrade"/>
        </ruleList>
        </folder>
     </folderList>
    
  • Avatar
    alejandror

    Is your installer using upgrade mode? Otherwise, the snippet will not work as the variable project.installationType would not be set to "upgrade". Additionally, it will likely fail due to both folders having the same name.

    As mentioned in my previous answer, you would need to follow this approach to set the overwritePolicy only for the folder containing the config file.

    <folderList> <folder> <description>Program Files</description> <destination>${installdir}</destination> <name>programfiles</name> <platforms>all</platforms> <distributionFileList> <distributionDirectory allowWildcards="1"> <origin>D:/InstallBuilder/SampleProject</origin> <excludeFiles>D:/InstallBuilder/SampleProject/config/configure.properties</excludeFiles> </distributionDirectory> </distributionFileList> </folder> <!-- folders before this one will use project's global overwritePolicy --> <!-- ... --> <folder> <name>dummy1</name> <actionList> <!-- change policy to never overwrite files --> <setInstallerVariable name="project.overwritePolicy" value="never"/> </actionList> </folder> <folder> <description>Program Files</description> <destination>${installdir}</destination> <name>configureproperties</name> <platforms>all</platforms> <distributionFileList> <distributionFile> <origin>D:/InstallBuilder/SampleProject/config/configure.properties</origin> </distributionFile> </distributionFileList> </folder> <folder> <name>dummy2</name> <actionList> <!-- change policy to always overwrite files --> <setInstallerVariable name="project.overwritePolicy" value="onlyIfNewer"/> </actionList> </folder> <!-- folders after one above will have overwritePolicy set to onlyIfNewer --> </folderList>

Please sign in to leave a comment.