[英]wix burn custom UI run silent overwriting default properties
我創建了 2 個簡單的 wix msi,並將它們捆綁到刻錄安裝程序中。 不喜歡 Burn 的默認 UI 我在這里找到了 Andrei Mușat 的自定義 UI 的絕佳示例: Custom BURN UI
我想以靜默模式運行它在 UI 引導程序中,運行 cmd:
protected override void Run()
{
Engine.Log(LogLevel.Verbose, "Entry point of WiX - Run method");
using (var container = SetupCompositionContainer())
{
bootstrapperBundleData = new BootstrapperBundleData();
Engine.Log(LogLevel.Verbose, JsonConvert.SerializeObject(bootstrapperBundleData));
// Create main window with associated view model
installerUIWindow = container.GetExportedValue<Window>("InstallerUIWindow");
installerUIWindowHandle = new WindowInteropHelper(installerUIWindow).EnsureHandle();
Engine.Detect();
if (Command.Display == Display.Passive || Command.Display == Display.Full)
{
installerUIWindow.Show();
}
else{
Engine.Log(LogLevel.Verbose, "Running silent mode");
}
Dispatcher.Run();
Engine.Quit(0);
Engine.Log(LogLevel.Verbose, "Exiting custom WPF UI.");
}
}
在 InstallerUIWINdowViewModel 中,我看到了這個:
InstallCommandValue = new DelegateCommand(
() => engine.Plan(LaunchAction.Install),
() => !Installing && Status == InstallationStatus.DetectedAbsent);
UninstallCommandValue = new DelegateCommand(
() => engine.Plan(LaunchAction.Uninstall),
() => !Installing && Status == InstallationStatus.DetectedPresent);
CancelCommandValue = new DelegateCommand(
() => IsCancelled = true);
那么如何在不顯示 UI 的情況下調用 InstallCmd 呢?
謝謝
該代碼並沒有真正針對該場景進行結構化。
我認為你想要做的是只創建 window 如果你打算顯示它,並創建視圖 model 如果你不這樣做(你只需要獲得 window 句柄) 然后,而不是調用Dispatcher.Run();
稱呼
Dispatcher.Invoke(() =>
{
if (installerVM.UninstallCommandValue.CanExecute())
{
installerVM.UninstallCommandValue.Execute();
}
if (installerVM.InstallCommandValue.CanExecute())
{
installerVM.InstallCommandValue.Execute();
}
});
我沒有對此進行測試,但看起來這應該可以完成工作(或者至少讓你更接近)。
讓我知道事情的后續。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.