2014-12-27 68 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

相关问题