在安装过程中需要CustomAction以从MSI获取文件nlbdb.bak。如何走上他的道路?
<Directory Id="ProgramFilesFolder">
<Directory Id="BACKUP" Name="BACKUP"/>
<Directory/>
<DirectoryRef Id="BACKUP">
<Component Id="VMBackup">
<File Id="Backup" Name="nlbdb.bak" Source="BACKUP\nlbdb.bak" DiskId="1" KeyPath="yes" />
</Component>
</DirectoryRef>
CA
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
string Directory = "";//get file path nlbdb.bak
bool test = File.Exists(Directory);
}
答案 0 :(得分:0)
您可以使用
访问自定义操作中的wix属性var propertyValue = session["MY_PROPERTY"];
在您的情况下,您将使用它来获取BACKUP
的值,该值将是文件的安装位置。显然你也可以根据需要连接文件名。
答案 1 :(得分:0)
使用session.Format方法,如下所示:
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
string path = session.Format("[#Backup]");
bool test = File.Exists(path);
return ActionResult.Success;
}
<CustomAction Id="CustomAction1" BinaryKey="CustomActions" DllEntry="CustomAction1" Execute="immediate" Return="check" Impersonate="yes"/>
<InstallExecuteSequence>
<Custom Action="CustomAction1" Before="InstallFinalize">Not Installed</Custom>
</InstallExecuteSequence>