安装包自定义操作参数传递

首先 在安装包中先添加自定义操作  如添加(主输出来自MyInstaller)

然后 右键“主输出来自MyInstaller”-属性

        设置CustomActionData属性

        如 /ProductCode=[ProductCode] /Solution="Solution1"

最后 在MyInstaller(继承自System.Configuration.Install.Installer)中获取参数

    [RunInstaller(true)]
    public class MyInstaller : System.Configuration.Install.Installer

    {

        private void GetParams()
        {
            //获取从安装程序“自定义操作”的CustomActionData属性中传过来的参数
            string szProductCode = Context.Parameters["ProductCode"];//获得 产品编号
            string szSolution = Context.Parameters["Solution"]; //获得 "Solution1"

        }

    }

原文地址:https://www.cnblogs.com/djian/p/2043656.html