Not sure if this is the best way but this is what I do; pass the install target directory to a custom actions project via the CustomActionData property like this:
/WebRoot="[TARGETDIR]\"
The MSI TARGETDIR is the directory the app was installed into. Then in the custom action project it can be accessed and used to get the config file like this:
string sConfigFile = Context.Parameters["WebRoot"].ToString() + "Web.config";
System.IO.FileInfo oFileInfo = new System.IO.FileInfo(sConfigFile);
XmlNode oNode;
if (oFileInfo.Exists)
{
//Loads the config file into the XML DOM.
XmlDocument oMyXMLDoc = new XmlDocument();
oMyXMLDoc.Load(oFileInfo.FullName);
oNode = oMyXMLDoc.DocumentElement.SelectSingleNode("//whatever....");
//modify xml nodes....
// Save changes
oMyXMLDoc.Save(oFileInfo.FullName);
}
else
{
throw (new InstallException("Error updating web configuration file. Missing file: " + oFileInfo.FullName));
}