File 在wix自定义操作中编辑inetpub文件夹中的文件

File 在wix自定义操作中编辑inetpub文件夹中的文件,file,iis,wix,File,Iis,Wix,我已经提到了这个问题,因为我需要在WIX安装期间编辑一个不是xml文件的文件。我正在通过wix部署一个网站,我需要根据用户输入在一个文件中进行一些更改 下面是我的自定义操作 <CustomAction Id="CustomActionID_Data" Property="CustActionId" Value="FileId=[#filBEFEF0F677712D0020C7ED04CB29C3BD];MYPROP=[MYPROP];"/> <CustomAction Id=

我已经提到了这个问题,因为我需要在WIX安装期间编辑一个不是xml文件的文件。我正在通过wix部署一个网站,我需要根据用户输入在一个文件中进行一些更改

下面是我的自定义操作

<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" />
由于这是在IISs intetpub文件夹下,我的操作会抛出错误,该文件正被另一个进程使用。有什么解决办法吗

若需要知道我的执行顺序,它是在安装文件之后,所以站点还并没有启动,但文件被复制

<InstallExecuteSequence>
  <Custom Action="CustomActionID_Data" Before="CustActionId">NOT REMOVE</Custom>
  <Custom Action="CustActionId" After="InstallFiles">NOT REMOVE</Custom>
</InstallExecuteSequence>

不删除
不删除

好的,我解决了这个问题。这既不是wix问题,也不是执行顺序。在上面的代码中,我打开了一个流来读取文本,并没有在阅读后处理它,这就是保存我资源的原因。我将代码改为下面的代码,一切正常

string data = "";
string prop= session.CustomActionData["MYPROP"];    
string path = session.CustomActionData["FileId"];
using(StreamReader f = File.OpenText(path)) // disposed StreamReader properly.
{
    data = f.ReadToEnd();
    data = Regex.Replace(data, "replacethistext", prop);
}
File.WriteAllText(path, data); 

只是想一想,是不是WIX安装程序本身已经获得了该文件,而自定义操作无法修改它,因为同样的原因?如果是,那怎么办?
string data = "";
string prop= session.CustomActionData["MYPROP"];    
string path = session.CustomActionData["FileId"];
using(StreamReader f = File.OpenText(path)) // disposed StreamReader properly.
{
    data = f.ReadToEnd();
    data = Regex.Replace(data, "replacethistext", prop);
}
File.WriteAllText(path, data);