Template Files Remove On Uninstall

May 14, 2012 at 5:07 PM
Edited May 14, 2012 at 5:08 PM

How can i remove the templated file on uninstall. In the example below "MyFile.ini" is left behind.  The same happens when you run the msiTemplateFiles uninstall

<File Id="File_template" Source=".\Source Files\MyFile.Template" Name="File.template" />
          <SystemTools:TemplateFile Id="File_template_process_component" Source="[#File_template]" ExecuteOnInstall="yes" target="[myDIR]Myfile.ini>         
            <SystemTools:TemplateFileProperty Id="P_MYPROP" Name="TESTPROP" Value="MyTestProp" />


The SystemTools.xsd states that the "Target" is optional for the template file, but if I omit it the compile fails telling me that it is not optional is this correct?.  To get intellisense I had to go to the source code directory and manually pull of the xsds.


      <xs:attribute name="Target" type="xs:string" use="optional">
          <xs:documentation>Target file to be written. When omitted, the source file is processed in-place and overwritten.</xs:documentation>

I am using Wix3.5 and MsiExt1.3 beta - i tried google code and google groups but they were empty and it seems that is the only place people are posting.

PS thanks for the work you have done - its really uselfull
May 15, 2012 at 11:09 AM

Just an update for those who may have a similar problem I fixed my issue by setting the Target property to the Source property to edit the file inline without installing an intermediate template file by simply setting the Target to the Source.  This also allows the uninstaller to remove the file.

An example is worth a thousand words so..


     <Component Id="C_iisproxy.ini" Guid="{3E94B46F-F4F2-4f04-B1C5-14902DABD515}">

          <!-- replace the proxy settings in place during install -->
          <File Id="iisproxy.ini" Name="iisproxy.ini" DiskId='1' Vital='yes' Source=".\Source Files\iisproxy.ini" />
          <SystemTools:TemplateFile Id="TF_iisproxy.ini" Source="[#iisproxy.ini]" Target="[#iisproxy.ini]"  ExecuteOnInstall="yes">         
            <SystemTools:TemplateFileProperty Id="P_HOST" Name="HOST" Value="[HOST]" />
            <SystemTools:TemplateFileProperty Id="P_PORT" Name="PORT" Value="[PORT]" />