Search code examples
wixwix3ini

Get INI file value with WiX


I'd like to read a value from an INI file in a WiX installer. I've just tried to use IniFileSearch, but this looks for an INI file or a path specified in an INI file (the documentation isn't clear), it doesn't read a value from an INI file.

Do I need a customaction to do this? And if so, what would people suggest? Seems very strange if WiX doesn't have this, though!

Code I'm using:

<Property Id="SP">
    <IniFileSearch Id="SearchSPVersion" Name="sp.ini" Section="ServicePack"
    Key="Version" Type="raw">
        <DirectorySearch Id="SPIniFilePath" Path="[CFGPATH]">
            <FileSearch Id="SPIniFile" Name="sp.ini"/>
        </DirectorySearch>
    </IniFileSearch>
</Property>

INI file:

[ServicePack] 
Version=1 

I've tried with and without the directory and file search (using full path in 'name'), and I've tried type = "raw", "file" and "directory".


Solution

  • Try this in a DTF custom action: INI File Reader in C#