我决定在这里提出问题,因为在其他任何地方都找不到答案。 我的任务是使用托管的引导程序UI准备升级过程,但它不想正常工作。 我准备了所有必需的MSI软件包。我的意思是我添加了产品ID =“ *”,添加了MajorUpgrade标记并对其进行了配置,并且我在捆绑软件之间更改了版本(出于测试目的),我还添加了一些属性,这有助于我区分是安装,卸载还是升级过程。
我的问题从这里开始,因为当我使用默认的刻录UI时,它正常工作是指在安装属性_INSTALL设置为1的过程中,升级(安装捆绑软件的版本2)期间,属性_UPGRADE设置为2,并且卸载,但是现在当我向其中添加自定义UI时,根本没有设置UPGRADE属性。在试用UPGRADE的过程中,它首先开始安装过程,然后到某个时候,然后出现带有卸载的新窗口。
我的问题是我可以以某种方式使自定义UI像默认的UI进行刻录吗?
答案 0 :(得分:0)
谢谢大家的评论。受How to perform Wix Upgrade with custom bootstrapper的启发,我知道当安装程序安静运行时,我无法处理这种情况。
所以我为SilentUninstall准备了另一个类,并在我的Bootstrapper类中完成了该操作:
public class BootstrapperApp : BootstrapperApplication
{
public static Dispatcher Dispatcher { get; set; }
protected override void Run()
{
Dispatcher = Dispatcher.CurrentDispatcher;
var model = new BootstrapperApplicationModel(this);
var command = model.BootstrapperApplication.Command;
if (command.Action == LaunchAction.Uninstall && (command.Display == Display.None || command.Display == Display.Embedded))
{
model.LogMessage("Starting silent uninstaller.");
var viewModel = new SilentUninstallViewModel(model, Engine);
Engine.Detect();
}
else
{
model.LogMessage("Starting installer.");
var viewModel = new InstallViewModel(model);
var view = new InstallView(viewModel);
view.Closed += (sender, e) => Dispatcher.InvokeShutdown();
model.SetWindowHandle(view);
Engine.Detect();
view.Show();
}
Dispatcher.Run();
Engine.Quit(model.FinalResult);
}}
和我的SilentUninstaller类:
public class SilentUninstallViewModel
{
private BootstrapperApplicationModel model;
private Engine engine;
public SilentUninstallViewModel(BootstrapperApplicationModel model, Engine engine)
{
this.model = model;
this.engine = engine;
WireUpEventHandlers();
}
private void WireUpEventHandlers()
{
this.model.BootstrapperApplication.PlanComplete += PlanCompleted;
this.model.BootstrapperApplication.DetectComplete += DetectCompleted;
this.model.BootstrapperApplication.ApplyComplete += ApplyCompleted;
}
private void DetectCompleted(object sender, DetectCompleteEventArgs e)
{
this.model.LogMessage("Detecting has been completed for silent uninstallation.");
this.model.PlanAction(LaunchAction.Uninstall);
}
private void ApplyCompleted(object sender, ApplyCompleteEventArgs e)
{
this.model.LogMessage("Applying has been completed for silent uninstallation.");
this.model.FinalResult = e.Status;
this.engine.Quit(this.model.FinalResult);
}
private void PlanCompleted(object sender, PlanCompleteEventArgs e)
{
this.model.LogMessage("Planning has been started for silent uninstallation.");
model.ApplyAction();
}
}
,它似乎正常工作。甚至在特定的MSI中也会引发_UPGRADE属性;)