1

My installer created with MS WiX installs a component (some files) into an existing folder in the user's App Data directory. This existing folder is empty. Thus, when uninstalling, the installer will remove this folder - which it shouldn't do. So how to prevent this?

The code is:

<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="LocalAppDataFolder" Name="AppData">
    <Directory Id="OtherCompanysFolder" Name="OtherCompany">
      <Directory Id="OtherProductsFolder" Name="Product">
        <Directory Id="AddOnsFolder" Name="AddOns">
          <Directory Id="MyAddOnFolder" Name="MyAddOn">
          </Directory>
        </Directory>
      </Directory>
    </Directory>
  </Directory>
</Directory>
</Fragment>

    <Fragment Id="AddOnFiles">
    <ComponentGroup Id="ProductComponents" Directory="MyAddOn">
      <Component Id="ProductComponent" Guid="{xxx}">
        <RegistryKey Root="HKCU" Key="Software\$(var.Manufacturer)\$(var.Product)">
          <RegistryValue Type="string" Value="" KeyPath="yes" />
        </RegistryKey>
        <RemoveFolder Id="RemoveMyAddOnFolder" On="uninstall" Directory="MyAddOnFolder" />
        <RemoveFolder Id="RemoveAddOnsFolder" On="uninstall" Directory="AddOnsFolder" />
        <RemoveFolder Id="RemoveOtherProductsFolder" On="uninstall" Directory="OtherProductsFolder" />
        <RemoveFolder Id="RemoveOtherCompanysFolder" On="uninstall" Directory="OtherCompany" />
        <File Id="Executable" Source="path\to\My.exe" />
      </Component>
    </ComponentGroup>
    </Fragment>

The problem is, if I remove the nodes

<RemoveFolder Id="RemoveAddOnsFolder" On="uninstall" Directory="AddOnsFolder" />
<RemoveFolder Id="RemoveOtherProductsFolder" On="uninstall" Directory="OtherProductsFolder" />
<RemoveFolder Id="RemoveOtherCompanysFolder" On="uninstall" Directory="OtherCompany" />

The Light and Ice will complain:

error LGHT0204 : ICE64: The directory AddOnsFolder is in the user profile but is not listed in the RemoveFile table.

Keepting these nodes makes Light and Ice happy, but it will remove AddOnsFolder (which it shouldn't do).

Any ideas what I could do?

PS: In the comment section it was recommended to suppress the error message with a flag (-sice:ICE64). This is NO solution. While the installer now compiles, the AddOn folder is still removed (which must not happen)

Philipp Sch
  • 348
  • 1
  • 6
  • _"Light and Ice will complain"_ -- copy+paste of exact error message please. – zett42 Jun 15 '19 at 11:52
  • I modfied my post and added the error message – Philipp Sch Jun 15 '19 at 14:19
  • 1
    Is this a per-user only setup? For per-machine setups I always recommend not installing to the user-profile folders, but to instead copy template files from a per-machine location to each user profile on application launch. Some links: [1](https://stackoverflow.com/questions/48189243/create-folder-and-file-on-current-user-profile-from-admin-profile), [2](https://stackoverflow.com/questions/45920700/why-is-it-a-good-idea-to-limit-deployment-of-files-to-the-user-profile-or-hkcu-w), [3](https://stackoverflow.com/questions/48695746/create-a-config-folder-in-the-user-folder/48697347#48697347). – Stein Åsmul Jun 16 '19 at 01:29
  • One "hack" is to install a marker / flag file as permanent so that the folder is not removed by MSI on uninstall. Maybe you could make that file hidden too, I didn't try. I suppose you could also suppress that validation error? Why is it critical to keep this folder? Custom ACL permissions? – Stein Åsmul Jun 16 '19 at 10:12
  • [Suppress ICE error](https://stackoverflow.com/a/7055515/129130) (Votive / Visual Studio). I think it is `-sice:ICE64` via the command line. – Stein Åsmul Jun 16 '19 at 10:31
  • And how to [suppress a specific ICE error](https://stackoverflow.com/a/31192979/129130) (not just all of them). – Stein Åsmul Jun 16 '19 at 10:45
  • Yes, this is a per-user only set up. I cannot install into another location since the app my add-on is for is in the user's appdata folder. It is crucial to keep this folder because if my add on is the first add on and it is uninstalled, the folder will become empty and removed by MSI. No other add ons can be installed (assuming other installers rely on an existing AddOn folder) – Philipp Sch Jun 19 '19 at 17:46
  • Suppressing the error is NO solution. The AddOns folder of the main program is still removed which must not happen – Philipp Sch Jun 28 '19 at 21:01
  • Did you solve this? – l33t Oct 29 '21 at 11:44
  • You don't need to worry about other installers. Windows Installer creates folder structure on install if it doesn't exist. – andrebroz Feb 05 '23 at 14:00

0 Answers0