2014-09-24 64 views
0

我已使用托管引导程序应用程序进行了编程设置。 在我的解决方案中有以下项目: - Setup.msi:要安装的MSI项目 - Setup.UI.dll:安装过程的WPF-GUI - Bootstrapper.exe:引导程序项目 - 启动程序.EXE:一个WPF-app启动引导程序无法从托管引导程序应用程序中的引导程序变量读取输入C#代码

在引导程序束我已经定义了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的受管引导程序,并且尝试读取安装路径时,我总是从定义中获取默认值:programfilesfolder。

这里从包的代码:

<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的代码:

string installationPath = UI.Model.Bootstrapper.Engine.FormatString(UI.Model.Bootstrapper.Engine.StringVariables["INSTALLFOLDER"]); 

和 - 至少 - 在SetupUI润方法:

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); 
} 

有人可以告诉我,我做错了什么?

回答

0

我自己找到了! 代码是正确的,但是当使用mannaged引导程序时,变量不会被覆盖。 所以我们必须在SetupUI中从BootstrapperApplication的CommandLineArguments中读取它们并将它们设置在变量中。 就是这样。