WiX Custom Action - Pass file list

2019-08-27 04:25发布

问题:

I am preparing installation packages for a plugin which replace some files of other application. I need make a backup of that files, so I prepared CustomAction which will do that.

How can I pass as argument to my custom action locations of all files which will be copied during installation? Do I need to make that list manually?

回答1:

Instead of creating a custom action, why not use the WiX CopyFile element to back up those files.



回答2:

You can pass parameters to custom actions by setting properties in your installer. Then access those properties in your custom action like so (C# example):

[CustomAction]
public static ActionResult DoWork(Session session)
{
    session.Log("Begin DoWork");
    string propertyValue = session["PROPERTYNAME"];
    //...
}