[英]WiX: how to access / change installation directory in managed bootstrapper?
我正在創建一個帶有自定義用戶界面的 WPF 安裝應用程序。 我從 Bryan P. Johnston 的教程開始: http : //bryanpjohnston.com/2012/09/28/custom-wix-managed-bootstrapper-application/
在我看來,我有一個簡單的TextBox
,它綁定到我的MainViewModel
的 Property InstallationPath
。
現在我希望在用戶單擊“安裝”時使用此路徑。 為此,我有一個綁定到我的InstallCommand
的按鈕。 調用以下方法(直接取自教程):
private void InstallExecute()
{
Bootstrapper.Engine.Plan(LaunchAction.Install);
}
如何將軟件包安裝到我的屬性InstallationPath
的目錄中?
編輯:
我在 Stackoverflow 上發現了一個類似的問題:
在 Burn 托管引導程序內指定 WiX 中包的 INSTALLLOCATION
答案來自 Bob Arnson
為每個 MsiPackage 使用 MsiProperty 子項來指定 INSTALLLOCATION=[BurnVariable]。 然后使用 Engine.StringVariables 設置 BurnVariable。
現在,我想我可以像這樣訪問我的InstallExecute
的StringVariables
private void InstallExecute()
{
Bootstrapper.Engine.StringVariables["BurnVariable"] = InstallationPath;
Bootstrapper.Engine.Plan(LaunchAction.Install);
}
但是在哪里定義這個變量呢? 我猜在 Product.wxs 的某個地方?
是的,只需在您的刻錄引導程序中創建一個變量:
<Variable Name="BurnVariable"
bal:Overridable="yes" />
然后,您可以將其作為參數傳遞給您的引導式 msi 包:
<MsiPackage SourceFile="$(var.YourMsiProject.Installer.TargetPath)" Compressed="no">
<MsiProperty Name="INSTALLLOCATION" Value="[BurnVariable]" />
</MsiPackage>
捆綁變量元素上缺少一個屬性“類型”。 caverman_dick 是對的,但是當不可覆蓋時這不能正常工作。 你也可以試試這個,設置 Type="string"。
<Wix>...<Bundle>...
<Variable Name="MyApplicationMsiInstallFolder" Value="[WindowsVolume]MyApplication"
bal:Overridable="yes" Type="string"/>
<Chain>
<?if $(var.DbVersion) = false?>
<PackageGroupRef Id="AccessDatabaseGroup"/>
<RollbackBoundary />
<?endif?>
<MsiPackage Id="MyApplicationMsiPackage" SourceFile="$(var.MyApplicationSetup.TargetPath)" DisplayInternalUI="no"
Vital="yes" >
<MsiProperty Name="APPLICATIONFOLDER" Value="[MyApplicationMsiInstallFolder]"/>
</MsiPackage>
</Chain>
</Bundle></Wix>
我也用這個傳奇教程。 我想將 veriable 用於其他用途。 即,該變量表示是否應安裝該程序。 問題是該變量在 InstallExecute() 中調用時不會覆蓋。 對於我的問題,它以這種方式工作:
protected override void Run()
{
this.Engine.Log(LogLevel.Verbose, "Launching custom TestBA UX");
BootstrapperDispatcher = Dispatcher.CurrentDispatcher;
MainViewModel viewModel = new MainViewModel(this);
viewModel.Bootstrapper.Engine.Detect();
MainView view = new MainView();
this.Engine.StringVariables["SqlStatus"] = view.CheckInstalledSQL() == true ? "true" : "false";
this.Engine.StringVariables["SsmsStatus"] = view.CheckInstalledSSMS() == true ? "true" : "false";
view.DataContext = viewModel;
view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
view.Show();
Dispatcher.Run();
this.Engine.Quit(0);
}
引導程序:
<Variable Name="SqlStatus" bal:Overridable="yes" Value="false" Type="string"/>
<Variable Name="SsmsStatus" bal:Overridable="yes" Value="false" Type="string"/>
...
<ExePackage Id="SSMS" Name="SQLServerManagementStudio" Cache="no" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes"
InstallCommand="/install /Passive SSMSInstallRoot=C:\\Program Files\\Microsoft SQL Server /norestart"
SourceFile="C:\Users\..\Downloads\SSMS-Setup-ENU.exe"
DetectCondition="SsmsStatus = "true""/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.