我已经使用托管引导程序应用程序编写了安装程序。在我的解决方案中有以下项目:- Setup.msi :要安装的MSI项目- Setup.UI.dll :用于安装过程的WPF-GUI - Bootstrapper.exe :引导程序项目- Launcher.exe :启动引导程序的WPF应用程序
在bootstrapper包中,我为installationfolder定义了一个变量:
<Variable Name="INSTALLFOLDER"
bal:Overridable="yes"
Type="string"
Value="[ProgramFilesFolder]"/>此变量可以在启动引导程序时由启动程序设置:
Process proc = new Process();
proc.StartInfo.FileName = "msiexec";
proc.StartInfo.FileName = "..\\..\\..\\Bootstrapper\\bin\\Debug\\Bootstrapper.exe";
proc.StartInfo.Arguments = "IsClientSetup=true INSTALLFOLDER=C:\\TestSetup";
proc.Start();如果我使用的是标准引导程序(WixStandardBootstrapperApplication.RtfLicense),我给出的条目将用在已定义的变量INSTALLFOLDER中。虽然在安装过程中我只看到了引导程序对话框,但毕竟一切都很好。
但是,当我使用托管引导程序启动我的WPF-GUI时,当我尝试读取安装路径时,我总是从定义中获得默认值:程序文件文件夹。
下面是捆绑包中的代码:
<WixVariable Id="WixMbaPrereqPackageId"
Value="Netfx4Full" />
<WixVariable Id="WixMbaPrereqLicenseUrl"
Value="NetfxLicense.rtf" />
<BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost" >
<Payload Name='BootstrapperCore.config' SourceFile='..\..\..\Setup.UI\bin\Debug\BootstrapperCore.config' />
<Payload SourceFile='..\..\..\Setup.UI\bin\Debug\SetupUI.dll' />
</BootstrapperApplicationRef>
<Chain>
<MsiPackage Id="SetupPackage"
SourceFile="..\..\..\Setup.Msi\bin\Debug\Setup.msi"
Cache="yes"
DisplayInternalUI="no"
Vital="yes"
Compressed="no"
EnableFeatureSelection="no"
DisplayName="SetupForTest">
<MsiProperty Name="INSTALLLOCATION"
Value="[INSTALLFOLDER]" />
</Chain>以及SetupUI中的ViewModel中的代码:
string installationPath = UI.Model.Bootstrapper.Engine.FormatString(UI.Model.Bootstrapper.Engine.StringVariables["INSTALLFOLDER"]);至少是SetupUI中的Run-method:
protected override void Run()
{
MessageBox.Show("1 = " + this.Engine.FormatString(this.Engine.StringVariables["INSTALLFOLDER"]));
Model = new Model(this);
Model.Bootstrapper.Engine.Detect();
MessageBox.Show("2 = " + Model.Bootstrapper.Engine.FormatString(Model.Bootstrapper.Engine.StringVariables["INSTALLFOLDER"]));
RootViewViewModel viewModel = new RootViewViewModel();
View = new RootView(viewModel);
// Populate the view models with data then run the view..
viewModel.Refresh();
View.Run();
this.Engine.Quit(0);
}谁能告诉我,我做错了什么?
发布于 2014-09-24 22:02:15
我自己找到的!代码是正确的,但是当使用人工引导程序时,变量不会被覆盖。因此,我们必须在SetupUI中从BootstrapperApplication的CommandLineArguments中读取它们,并在变量中设置它们。就这样。
https://stackoverflow.com/questions/26012281
复制相似问题