2014-12-27 36 views
1

我需要允許用戶更改安裝位置。我試過這個解決方案questionWiX-如何允許用戶更改引導程序上的安裝位置

我需要將我的wix msi文件添加到我的引導程序項目中。 下面是我的微星項目代碼,

<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> 

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> 
    <MediaTemplate /> 

    <Feature Id="ProductFeature" Title="SetupProject1" Level="1"> 
     <ComponentRef Id="ProductComponent" /> 
    </Feature> 
</Product> 

<Fragment> 
    <Directory Id="TARGETDIR" Name="SourceDir" src="[TARGETDIR]"> 
      <Directory Id="INSTALLFOLDER" Name="SetupProject1"> 
     <Component Id="ProductComponent" Guid="2ACAD378-270B-4B50-AAED-A234A6BB8276"> 
     <File Name="$(var.WindowsFormsApplication2.TargetFileName)" Source="$(var.WindowsFormsApplication2.TargetPath)" /> 
     </Component> 
    </Directory> 
    </Directory> 
</Fragment> 

<Fragment> 
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> 
    </ComponentGroup> 
</Fragment> 

以下是引導程序代碼,

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

    <Chain> 
    <MsiPackage 
    Id="MyService" 
    Name="MyService" 
    SourceFile="..\SetupProject1\bin\Release\SetupProject1.msi" 
    DisplayInternalUI="yes" 
    EnableFeatureSelection="yes" 
    Compressed="yes" 
    Vital="yes" > 
    <MsiProperty Name="TARGETDIR" Value="[varInstallLocation]"/> 
    </MsiPackage> 
    </Chain> 
</Bundle> 

回答

2

您使用的是標準的引導程序? RtfLicense或HyperlinkLicense?

如果您在Wix標準boostrapper中設置了SuppressOptionsUI="no",則會顯示一個選項按鈕,以便用戶手動修改安裝位置。

<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense"> 
    <bal:WixStandardBootstrapperApplication 
    SuppressOptionsUI="no" 
    /> 
</BootstrapperApplicationRef> 

然後你提到安裝MSI包內的MSI屬性,這將隨後與用戶有所回升的位置覆蓋。

<MsiProperty Name="INSTALLFOLDER" Value="[InstallFolder]" /> 

如果要設置默認安裝位置,請將該捆綁包中的變量設置爲默認值。

<Variable Name="InstallFolder" Type="string" Value="[ProgramFilesFolder]Install"/> 
+0

我無法設置默認安裝位置。我正在使用RtfLicense模板,並設置了變量(在Bundle內部但在外部鏈中),但初始安裝文件夾爲空。 – bubi 2017-09-17 16:21:07

相關問題