2013-02-22 51 views
6

我正在用自定義用戶界面創建一個WPF設置應用程序。我開始與布萊恩P.約翰斯頓的教程:http://bryanpjohnston.com/2012/09/28/custom-wix-managed-bootstrapper-application/WiX:如何訪問/更改託管引導程序中的安裝目錄?

某處在我看來,我有一個簡單TextBox結合到物業InstallationPath在我MainViewModel

現在我想,當用戶點擊「安裝」要使用此路徑。爲此,我有一個按鈕綁定到我的InstallCommand。下面的方法被調用(直接從本教程獲取):

private void InstallExecute() 
{ 
    Bootstrapper.Engine.Plan(LaunchAction.Install); 
} 

我怎樣才能讓包被安裝到我的財產InstallationPath的目錄?


編輯:

我發現了一個類似的問題在這裏#2:

Specify the INSTALLLOCATION of packages in WiX inside the Burn managed bootstrapper

答案有來自鮑勃Arnson

使用的MsiProperty孩子每MsiPackage指定INSTALLLOCATION = [BurnVariable]。然後使用Engine.StringVariables設置BurnVariable。

現在,我想我可以進入StringVariables在我InstallExecute這樣

private void InstallExecute() 
{ 
    Bootstrapper.Engine.StringVariables["BurnVariable"] = InstallationPath; 
    Bootstrapper.Engine.Plan(LaunchAction.Install); 
} 

但是,在定義這個變量?我想在Product.wxs的某個地方?

+0

喂邁克爾,我遵循了這一相同的教程,我在那裏面臨重大升級過程中,先前的exe文件是沒有得到新的一個並排安裝刪除的問題。我增加了EXE版本和附帶的MSI版本。我看到一些其他人在教程下面評論同樣的問題。你遇到過這個問題嗎?如果是的話,你是如何克服它的? :(需要一些幫助人 – mayooran 2016-04-27 02:31:58

回答

8

是隻需在您的刻錄引導程序創建一個變量:

<Variable Name="BurnVariable" 
      bal:Overridable="yes" /> 

然後你可以通過這個作爲參數傳遞給您的自舉MSI軟件包:

<MsiPackage SourceFile="$(var.YourMsiProject.Installer.TargetPath)" Compressed="no"> 
    <MsiProperty Name="INSTALLLOCATION" Value="[BurnVariable]" />   
</MsiPackage> 
+0

謝謝!這就是我正在尋找的。:-) – 2013-02-22 16:20:37

1

一人失蹤屬性「類型」在Bundle變量元素上。 caverman_dick是正確的,但不能正常工作時不可覆蓋。 你也可以試試這個,設置Type =「string」。

Wix Variable Element

<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> 
相關問題