views:

322

answers:

3

I am using WiX to install a plugin for a software that I am not controlling. To install the plugin, I have to put the target folder in a registry key:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="LocalAppDataFolder">
    <Directory Id="APPROOTFOLDER" Name="Foobar Plugin" />
  </Directory>
</Directory>

...

<DirectoryRef Id="APPROOTFOLDER">
  <Component Id="register" Guid="240C21CC-D53B-45A7-94BD-6833CF1568BE">
    <RegistryKey Root="HKCU" Key="Software\ACME\Plugins\FooBar">
      <RegistryValue Name="InstallDir" Value="[APPROOTFOLDER]" Type="string"/>
    </RegistryKey>
  </RegistryKey>
</DirectoryRef>

After the installation, the registry key HKCU\Software\ACME\Plugins\FooBar\InstallDir will contain the installation target path, but with a trailing "\". Unfortunately, for some strange reasons, the host application (the provides the plugin architecture) crashes due to that. If there is no trailing slash, everything works fine!

Is there a way in WiX to get rid of the trailing slash?

One solution I was thinking of is simply adding a "." at the end of the path, however, this seems not to work in my scenario :( ..

+1  A: 

As far as I know, Windows Installer doesn't provide any string manipulation natively, so this is going to require a custom action.

tsellon
+1  A: 

The only string manipulation you really have in Windows Installer is the manipulation of formatted data types. See MSDN for more information.

Windows Installer provides a trailing directory separator by design, so there isn't any way to remove this aside from a custom action. I'd suggest lodging a bug with the developers of the source package you're developing a plugin for, if you're encountering this error then other developers likely are too.

sascha
+2  A: 

You can always do something like this:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="LocalAppDataFolder">
    <Directory Id="APPROOTFOLDER" Name="Foobar Plugin" />
  </Directory>
</Directory>

...

<DirectoryRef Id="APPROOTFOLDER">
  <Component Id="register" Guid="240C21CC-D53B-45A7-94BD-6833CF1568BE">
    <RegistryKey Root="HKCU" Key="Software\ACME\Plugins\FooBar">
      <RegistryValue Name="InstallDir" Value="[LocalAppDataFolder]\Foobar Plugin" Type="string"/>
    </RegistryKey>
  </RegistryKey>
</DirectoryRef>

And don't allow the user to change the final folder

Shay Erlichmen
Yeah, that's true! Because the hosting application also has problems with double-slashes, I remove the one in front of "Foobar Plugin" and it should be fine.. Thanks!
beef2k