2014-09-24 59 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中讀取它們並將它們設置在變量中。 就是這樣。