I have reffered this question as I need to edit a file during WIX installation which is not a xml file. I am deploying a web site through wix and I need to make some changes in one file according to the user input.
Below are my custom actions
<CustomAction Id="CustomActionID_Data" Property="CustActionId" Value="FileId=[#filBEFEF0F677712D0020C7ED04CB29C3BD];MYPROP=[MYPROP];"/>
<CustomAction Id="CustActionId"
Execute="deferred"
Impersonate="no"
Return="ignore"
BinaryKey="CustomActions.dll"
DllEntry="EditFile" />
and below is the code in custom action.
string prop= session.CustomActionData["MYPROP"];
string path = session.CustomActionData["FileId"];
StreamReader f = File.OpenText(path);
string data = f.ReadToEnd();
data = Regex.Replace(data, "replacethistext", prop);
File.WriteAllText(path, data); // This throws exception.
As this is under IISs intetpub folder my action throws error that file is being used by another process. Any solutions?
If need to know my execution sequence, it is after installfiles so site is not yet started but files are copied.
<InstallExecuteSequence>
<Custom Action="CustomActionID_Data" Before="CustActionId">NOT REMOVE</Custom>
<Custom Action="CustActionId" After="InstallFiles">NOT REMOVE</Custom>
</InstallExecuteSequence>