WiX在自定义操作执行期间显示文本

时间:2019-05-23 12:24:28

标签: c# wix custom-action

我希望我的wix安装程序对话框上的文本框显示我的自定义操作的进度。

这是执行的自定义操作代码,我想写出以下每一行:

dacServiceInstance.Message += (s, e) => MessageList += Environment.NewLine + e.Message.Message;

并在执行时在文本框中显示该项目:

public static bool ProcessDacPac(string connectionString, string databaseName, string dacpacName, Session session)
{
    var success = true;
    //var MessageList = new List<string>
    //{
    //    "*** Start of processing for " +  databaseName
    //};

    var MessageList = "*** Start of processing for " + databaseName;

    var dacOptions = new DacDeployOptions { BlockOnPossibleDataLoss = false };

    var dacServiceInstance = new DacServices(connectionString);
    //dacServiceInstance.ProgressChanged += (s, e) => MessageList.Add(e.Message);
    //dacServiceInstance.Message += (s, e) => MessageList.Add(e.Message.Message);

    dacServiceInstance.ProgressChanged += (s, e) => MessageList += Environment.NewLine + e.Message;
    dacServiceInstance.Message += (s, e) => MessageList += Environment.NewLine + e.Message.Message;

    try
    {
        using (var dacpac = DacPackage.Load(dacpacName))
        {
            dacServiceInstance.Deploy(dacpac, databaseName,
                upgradeExisting: false,
                options: dacOptions);
        }
    }
    catch (Exception ex)
    {
        success = false;
        //MessageList.Add(ex.Message);
        MessageList += Environment.NewLine + ex.Message;
    }

    session["MESSAGE_LIST"] = MessageList;
    //WinForms.MessageBox.Show(MessageList);
    //session.SetObjectAsJson("MessageList", MessageList);
    return success;
}

这是我的WiX控件:

<Control Id="Progress" Type="Edit" X="45" Y="127" Width="160" Height="80" Property="MESSAGE_LIST" Text="[MESSAGE_LIST]">
</Control>

我希望执行时会在文本框中显示MESSAGE_LIST的结果。

0 个答案:

没有答案