Remove trailing slash from tracks in WiX

I use WiX to install a plugin for software that I do not control. To install the plugin, I have to put the target folder in the 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 installation, the registry HKCU\Software\ACME\Plugins\FooBar\InstallDir will contain the target installation path, but with a final " \ ". Unfortunately, for some strange reason, because of this, because of this, the main application (providing the plugin architecture) fails. If there is no slash, everything works fine!

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

One of the solutions I was thinking about is to simply add a β€œ . ” At the end of the path, however it doesn't seem to work in my scenario :( ..

+7
installer path wix
source share
4 answers

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 do not let the user change the destination folder

+2
source share

You should not use scripts in custom actions, but if you can limit only a few lines and something simple like this example, you should be Ok ...

 <CustomAction Id="VBScriptCommand" Script="vbscript"> <![CDATA[ value = Session.Property("INSTALLFOLDER") If Right(value, 1) = "\" Then value = Left(value, Len(value) - 1) End If Session.Property("SOME_PROPERTY") = value ]]> </CustomAction> <InstallExecuteSequence> <Custom Action="VBScriptCommand" After="CostFinalize">NOT REMOVE</Custom> </InstallExecuteSequence> 
+4
source share

As far as I know, the Windows installer does not provide any string manipulation initially, so this will require a special action.

+1
source share

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

Windows Installer provides a design end directory designer, so there is no way to remove this other than a custom action. I suggest posting a bug with the developers of the source package for which you are developing a plugin, if you encounter this error, other developers may also be.

+1
source share

All Articles