0

Here's what I have (based on what I've gleaned from several other Stack Overflow posts and elsewhere:

<Property Id="CACHEFOLDER">
  <RegistrySearch Key="SOFTWARE\SIL\Transcelerator" Root="HKCU" Type="raw"
    Id="CacheFolderRegSearch" Name="CachePath" />
</Property>

<Directory Id="TARGETDIR" Name="SourceDir
  <!-- Transcelerator's cache folder in LocalAppData: -->
  <!-- C:\Users\<current user>\AppData\Local\SIL\Transcelerator -->
  <!-- This needs to be saved to a registry key so it can be cleaned up on uninstall and also purged when there is a new install in order to ensure that reparsing occurs. -->
  <?define AppCacheFolder = "SIL\Transcelerator" ?>
  <Component Id="CacheCleanup" Guid="{6A45D61D-EA73-4A8C-8941-B49A881ABB49}">
    <RegistryValue Root="HKCU" Key="Software\SIL\Transcelerator" Name="CachePath" 
                   Type="string" Value="[LocalAppData]$(var.AppCacheFolder)"                   
                   KeyPath="yes" />
    <util:RemoveFolderEx On="both" Property="CACHEFOLDER"/>
  </Component>

</Directory>

<Feature Id="MainApplication" Title="App Name" Level="1" Absent="disallow" Display="expand" AllowAdvertise="no" InstallDefault="local">
  <ComponentRef Id="CacheCleanup" />
</Feature>

Note: Eventually, I'll want to make the MainApplication feature hidden, but for now it's comforting to see it.

Here are what I think are the relevant excerpts from the WIX log file:

AppSearch: Property: CACHEFOLDER, Signature: CacheFolderRegSearch MSI (c) (38:F0) [18:25:39:116]: PROPERTY CHANGE: Adding CACHEFOLDER property. Its value is 'SIL\Transcelerator'. Action ended 18:25:39: AppSearch. Return value 1.

...

MSI (c) (38:F0) [18:25:45:594]: Switching to server: PARATEXT7="C:\Program Files (x86)\Paratext 7\" PARATEXT7TEST="C:\Program Files (x86)\ParatextDir7Test\" PARATEXT8="C:\Program Files (x86)\Paratext 8\" PARATEXT8TEST="C:\Program Files (x86)\ParatextDir8Test\" PARATEXT75100ORGREATER="C:\Program Files (x86)\Paratext 7\Paratext.exe" CACHEFOLDER="SIL\Transcelerator" TARGETDIR="C:\" INSTALLDIR7="C:\Program Files (x86)\Paratext 7\plugins\Transcelerator\" INSTALLDIR7TEST="C:\Program Files (x86)\ParatextDir7Test\plugins\Transcelerator\" INSTALLDIR8="C:\Program Files (x86)\Paratext 8\plugins\Transcelerator\" INSTALLDIR8TEST="C:\Program Files (x86)\ParatextDir8Test\plugins\Transcelerator\" PLUGINDIR7="C:\Program Files (x86)\Paratext 7\plugins\" PLUGINDIR7TEST="C:\Program Files (x86)\ParatextDir7Test\plugins\" PLUGINDIR8="C:\Program Files (x86)\Paratext 8\plugins\" PLUGINDIR8TEST="C:\Program Files (x86)\ParatextDir8Test\plugins\" CURRENTDIRECTORY="C:\Projects\Transcelerator" CLIENTUILEVEL="0" CLIENTPROCESSID="17976" SOURCEDIR="C:\Projects\Transcelerator\output\installer\" ACTION="INSTALL" EXE

...

MSI (s) (E4:44) [18:25:46:006]: PROPERTY CHANGE: Adding CACHEFOLDER property. Its value is 'SIL\Transcelerator'.

...

Action 18:25:46: WixRemoveFoldersEx. Action start 18:25:46: WixRemoveFoldersEx. MSI (s) (E4:00) [18:25:46:041]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI6019.tmp, Entrypoint: WixRemoveFoldersEx MSI (s) (E4:78) [18:25:46:042]: Generating random cookie. MSI (s) (E4:78) [18:25:46:044]: Created Custom Action Server with PID 18712 (0x4918). MSI (s) (E4:54) [18:25:46:067]: Running as a service. MSI (s) (E4:54) [18:25:46:069]: Hello, I'm your 32bit Impersonated custom action server. WixRemoveFoldersEx: Recursing path: SIL\Transcelerator\ for row: wrfA9D8B049E87ACFF02034C5FFCFB64E42. WixRemoveFoldersEx: Search path not found: SIL\Transcelerator* Action ended 18:25:46: WixRemoveFoldersEx. Return value 1.

...

MSI (s) (E4:44) [18:25:46:267]: Executing op: ComponentRegister(ComponentId={6A45D61D-EA73-4A8C-8941-B49A881ABB49},KeyPath=01:\Software\SIL\Transcelerator\CachePath,State=3,,Disk=1,SharedDllRefCount=0,BinaryType=0) 1: {97A212AC-E01E-486A-A220-AF9BBBC79E87} 2: {6A45D61D-EA73-4A8C-8941-B49A881ABB49} 3: 01:\Software\SIL\Transcelerator\CachePath

...

MSI (s) (E4:44) [18:25:46:597]: Executing op: RegOpenKey(Root=-2147483647,Key=Software\SIL\Transcelerator,,BinaryType=0,,) MSI (s) (E4:44) [18:25:46:597]: Executing op: RegAddValue(Name=CachePath,Value=SIL\Transcelerator,) WriteRegistryValues: Key: \Software\SIL\Transcelerator, Name: CachePath, Value: SIL\Transcelerator

...

Property(S): CACHEFOLDER = SIL\Transcelerator

Nothing relevant seems to be getting added to the registry. (At one point, it seems it was adding something withe correct GUID to tell it to do an uninstall action, but now I can't figure out what I changed to make that go away.) And none of files or subfolders in C:\Users\bogle\AppData\Local\SIL\Transcelerator are getting removed either on install or uninstall. I also tried changing from On="both" to On="Uninstall" to see if I could get that to work, but no dice.

Tom Bogle
  • 464
  • 4
  • 18
  • "SIL\Transcelerator" isn't a valid full path? The information on RemoveFolderEx's Property attribute says that it is "The id of a property that resolves to the full path of the source directory. " You want CACHEFOLDER to be "C:\Users\bogle\AppData\Local\SIL\Transcelerator" – Brian Sutherland Nov 23 '17 at 15:21
  • Yes, but I can't figure out how to make that happen. – Tom Bogle Nov 27 '17 at 01:35
  • According to [this article](https://stackoverflow.com/questions/47195875/wix-remove-localappdata-appdata-local-my-app-folder-on-uninstall) and others, putting [LocalAppData] in the RegistryKey's Value attribute should cause it to prepend the rooted path to the current user's AppData\Local folder, but it's not working for me. – Tom Bogle Nov 27 '17 at 02:41
  • When I've used RemoveFolderEx I've just read a registry key that had the full path as its value like the article you linked. It looks like the property name should actually be "LocalAppDataFolder" https://msdn.microsoft.com/en-us/library/aa369768(v=vs.85).aspx – Brian Sutherland Nov 27 '17 at 15:37
  • I tried LocalAppDataFolder as well, but it made no difference. – Tom Bogle Nov 29 '17 at 17:36

2 Answers2

0

I ended up using a custom action because it turns out that what I really needed to do was clear the cached files for any/all users, not just the current user. This was especially true because the installer always runs under elevated privileges, so the current user quite typically would not be the one I actually care about. I will point out that the original problem remains unsolved, so if anyone can figure out the problem and post an alternate answer that might help someone else, that could be useful.

Tom Bogle
  • 464
  • 4
  • 18
0

The name of the directory property is LocalAppDataFolder, not LocalAppData. That's not defined so it's an empty string and the path RemoveFolderEx is given isn't valid (hence the Search path not found: SIL\Transcelerator error).

Bob Arnson
  • 21,377
  • 2
  • 40
  • 47