2

我们有一个 wix 设置(基于 wix 版本 3.9)和一个标准 wix 包以及一个显示 wpf gui(带有 Bootstrapper 等)的所谓捆绑包,我们可以在其中安装、更新和卸载shabang。就我所见,一切都应该“按部就班”……

现在问题来了:我们可以通过更改版本号来升级,但我们似乎无法在此过程中禁用卸载 GUI 以弹出。

我的想法已经用完了,这是其他人必须解决的问题,但我没有找到任何真正的解决方案。

由于它是在 C# 中针对所谓的引擎进行管理的,因此我们需要某种代码。

目前代码是这样的。在我的 BA 类的 Run 方法中:

    protected override void Run()
    {
        Dispatcher = Dispatcher.CurrentDispatcher;
        var model = new BootstrapperApplicationModel(this);
        Logging logging = new Logging(model);
        var view = new MainView(model, logging, this.RunMode);
        model.SetWindowHandle(view);
        this.Engine.Detect();
        view.Show();
        Dispatcher.Run();
        this.Engine.Quit(model.FinalResult);
    }

然后在 MainView 类(或者实际上是后面的视图模型)中对此进行操作:

    public void Activate(BootstrapperApplicationModel appModel, Logging modelLogging, LaunchAction runMode)
    {
        this.launchAction = runMode;
        this.model = appModel;
        this.logging = modelLogging;
        this.WireUpEventHandlers();
        this.OpenStartPageView();
    }

    private void WireUpEventHandlers()
    {
        this.model.BootstrapperApplication.PlanComplete += this.PlanComplete;
        this.model.BootstrapperApplication.ApplyComplete += this.ApplyComplete;
        this.model.BootstrapperApplication.ApplyBegin += this.ApplyBegin;
        this.model.BootstrapperApplication.ExecutePackageBegin += this.ExecutePackageBegin;
        this.model.BootstrapperApplication.ExecutePackageComplete += this.ExecutePackageComplete;
        this.model.BootstrapperApplication.PlanMsiFeature += this.SetPlannedFeature;
        this.model.BootstrapperApplication.DetectMsiFeature += SetFeatureDetectedState;
        this.model.BootstrapperApplication.DetectRelatedBundle += this.DetectRelatedBundle;
        this.model.BootstrapperApplication.DetectPackageComplete += this.DetectPackageComplete;
        this.model.BootstrapperApplication.Engine.Detect();
    }

希望这可能会给我们一些如何设置 gui 的想法。

感觉在激活函数中我需要类似下面的附加 if case:

    public void Activate(BootstrapperApplicationModel appModel, Logging modelLogging, LaunchAction runMode)
    {
        this.launchAction = runMode;
        this.model = appModel;
        this.logging = modelLogging;
        if (this.launchAction == LaunchAction.Uninstall && /* something */)
        {
            this.model.PlanAction(this.launchAction); // Uninstall
            return;
        }

        this.WireUpEventHandlers();
        this.OpenStartPageView();
    }

但我不知道如何传递来自不同版本的信息......

提前致谢!

4

1 回答 1

2

进行升级时,较新版本的安装将使用/q 参数调用先前版本的安装,这将为安装程序 BA 提供Command.Display = Display.None 或 Display.Embedded

因此,在上面带有 if-case 的示例中,它将如下所示:

    public void Activate(BootstrapperApplicationModel appModel, Logging modelLogging, 
                         LaunchAction runMode, Display display)
    {
        this.launchAction = runMode;
        this.model = appModel;
        this.logging = modelLogging;
        this.displayMode = display;
        if (this.launchAction == LaunchAction.Uninstall && 
            (this.displayMode == Display.None || this.displayMode == Display.Embedded))
        {
            this.model.PlanAction(this.launchAction); // Uninstall
            return;
        }

        this.WireUpEventHandlers();
        this.OpenStartPageView();
    }

解释我上面做了什么:

  • 在函数调用中添加了Display in-parementer
  • 扩展 if 以处理Display.NoneDisplay.Embedded
于 2016-03-10T09:06:23.610 回答