0
votes

I'm building a MSI setup file using WiX Toolset v3.10.2. I'm using InstallScope='perMachine' so the program gets installed in the Program Files folder.

However, I need to install one (settings) file to the Application Data Roaming folder of the current user.

<Directory Id="AppDataFolder">
    <Directory Id="ManufacturerAppDataFolder" Name="Manufacturer">
        <Directory Id="ProductAppDataFolder" Name="ProductName">
            <Component Id="AppDataConfig" Guid="643DB270-8D85-467B-A6BA-9A54924655E0" Feature="MainApplication">
                <RemoveFolder Id='RemoveProductAppDataFolder' Directory='ProductAppDataFolder' On='uninstall' />
                <RemoveFolder Id='RemoveManufacturerAppDataFolder' Directory='ManufacturerAppDataFolder' On='uninstall' />
                <RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Name="UserConfigLocation" Value='[ProductAppDataFolder]' KeyPath='yes' />
                <File Source="Files\user.settings" />
            </Component>
        </Directory>
    </Directory>
</Directory>      

I'm getting this warning when I'm running light.exe:

warning LGHT1076 : ICE91: The file 'user.settings' will be installed
to the per user directory 'ProductAppDataFolder' that doesn't vary based
on ALLUSERS value. This file won't be copied to each user's profile even
if a per machine installation is desired.

I'm installing the MSI on the administrator user ("FirstUser") of a Windows 10 PC, and the settings file is correctly installed at

c:\Users\FirstUser\AppData\Roaming\Manufacturer\ProductName\user.settings

If I login to another user account ("SecondUser"), a new settings file appears at

c:\Users\SecondUser\AppData\Roaming\Manufacturer\ProductName\user.settings

However, after I run the uninstall program while logged in the administrator account ("FirstUser"), the settings file is only deleted from the AppData folder of the FirstUser. The settings file in the AppData folder of the SecondUser is not deleted, it is left on disk.

What is the proper way to install a file in the Application Data folder, so it gets created for every user, and also removed for every user on uninstall?

1
"Install a file in the Application Data folder, so it gets created for every user": let the application create it. It doesn't get installed. It doesn't get uninstalled. See the blog @PhilDW referenced.Tom Blodget

1 Answers

2
votes

It looks like you're doing it the right way already. The uninstall can't reliably enumerate all the other profiles to remove the data. See also:

https://blogs.msdn.microsoft.com/oldnewthing/20070917-00/?p=25103/

An alternative could be to redesign the app if the left-over files are a big deal. Each user's settings could be in a DB or Xml file (as examples) in a per-machine location where it could be removed on uninstall (assuming it's not being upgraded).

You're getting the warning because the ICE tests are static - they don't know if the install will be per user or per machine. It's badly worded - it means the per machine install won't install the file to each user's version of the directory.