【问题标题】:Change install directory WIX Bootstrapper更改安装目录 WIX Bootstrapper
【发布时间】:2013-06-23 06:15:16
【问题描述】:

在自定义引导程序项目中替换我的 WIX 项目的安装目录时遇到问题。该解决方案包含 3 个项目(Custom Bootstrapper、Installer Project 和 BootstrapperSetup)。

安装程序项目中的 product.wcs 如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<?include $(sys.CURRENTDIR)\Settings\settings.wxi ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">

<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="1.0.0.0" Manufacturer="$(var.Manufacturer)" UpgradeCode="f4c5c824-17e9-4897-9af0-49b2b1225251">
<Package InstallerVersion="300" Compressed="yes" InstallScope="perMachine" />

<MajorUpgrade DowngradeErrorMessage="A newer version of $(var.ProductName) is already installed." />
<MediaTemplate />

<Property Id="PRODUCTNAME" Value="$(var.ProductName)" />
<Property Id="INSTALL_LOCATION" Value="ApplicationInstallDir"/>

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="$(var.PlatformProgramFilesFolder)" Name="PFiles">
    <Directory Id="DirManufacturer" Name="$(var.Manufacturer)">
      <Directory Id="ApplicationInstallDir" Name="$(var.ProductName)">
        <Component Id="ProductComponent" KeyPath="yes" Guid="28982BC3-BCEA-4EAF-9E7E-9E19A9355CFA">
          <File Id="Norma12" Name="$(var.Norma 12.TargetFileName)" Source="$(var.Norma 12.TargetPath)" DiskId="1" />
          <CreateFolder />
        </Component>
      </Directory>
    </Directory>
  </Directory>
</Directory>

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

</Product>
</Wix>

bundle.wxs 如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<?include $(sys.CURRENTDIR)\Settings\settings.wxi ?> 

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" 
 xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
 xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">

<Bundle Name="$(var.ApplicationName)" Version="$(var.Version)" Manufacturer="$(var.Manufacturer)" 
      UpgradeCode="ba657b0d-46d6-452a-aa4c-4212dda03d52"
      Copyright="Copyright (c) 2013 $(var.Manufacturer). All rights reserved."
      HelpUrl="http://www.miconsultancy.com" AboutUrl="http://www.miconsultancy.com">

<BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost">
  <Payload SourceFile="$(var.MI Wix.TargetDir)\BootstrapperCore.config"/>
  <Payload SourceFile="$(var.MI Wix.TargetPath)"/>
  <Payload SourceFile="C:\Program Files (x86)\WiX Toolset v3.7\SDK\Microsoft.Deployment.WindowsInstaller.dll"/>
</BootstrapperApplicationRef>

<Variable Name="ProjectName" Type="string" Value="$(var.ApplicationName)"  />
<Variable Name="LicenseRTF" Type="string" Value="$(var.MI Wix.ProjectDir)\License\mi_lic.rtf"/>
<Variable Name="ProductID" Type="string" Value="$(var.ApplicationID)"/>
<Variable Name="varInstallLocation" Type="string" Value="\$(var.Manufacturer)\$(var.ApplicationName)"/>

<Chain>
  <!-- TODO: Define the list of chained packages. -->
  <PackageGroupRef Id='Netfx4Full' />

  <MsiPackage Compressed="yes"
              SourceFile="$(var.InstallerProject.TargetPath)"
              Vital="yes" Id="$(var.ApplicationID)" >
    <MsiProperty Name="INSTALL_LOCATION" Value="[varInstallLocation]"/>
  </MsiPackage>
    </Chain>
</Bundle>

<Fragment>
<!-- Managed bootstrapper requires .NET as a dependency, since it was written in .NET.
   WiX provides a Bootstrapper for the bootstrapper. The fragment below includes .NET.
   For more information or examples see Heath Stewart's blog or the WiX source:
   http://blogs.msdn.com/b/heaths/archive/2011/10/28/introducing-managed-bootstrapper-applications.aspx
   -->

<WixVariable Id="WixMbaPrereqPackageId" Value="Netfx4Full" />
<WixVariable Id="WixMbaPrereqLicenseUrl" Value="NetfxLicense.rtf" />

<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" Value="Version" Variable="Netfx4FullVersion" />
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" Value="Version" Variable="Netfx4x64FullVersion" Win64="yes" />

<PackageGroup Id="Netfx4Full">
  <ExePackage Id="Netfx4Full" Cache="no" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes"
              SourceFile="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFX40\dotNetFx40_Full_x86_x64.exe"
              DownloadUrl="http://go.microsoft.com/fwlink/?LinkId=164193"
              DetectCondition="Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion)" />
</PackageGroup>
</Fragment>
</Wix>

变量 varInstallLocation 需要在自定义引导程序中更改,这是通过:

BootstrapperApplication.Engine.StringVariables("varInstallLocation") = s_installDirectory

但是当我在代码中保存时,新的安装路径不会存储到变量中,应用程序将安装在默认位置。有人可以帮我看看吗。

【问题讨论】:

  • 检查 %TEMP%\BootstrapperSetup_.log 中的引导程序安装日志。它应该显示引导程序变量的初始值和每次更改。安装程序安装日志 %TEMP%\BootstrapperSetup__.log 将显示传递给 MsiPackage 的属性。

标签: vb.net wix bootstrapper


【解决方案1】:

确保在调用Engine.Apply() 之前设置变量。之后设置的变量将不会提供给链接的包。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-26
    • 1970-01-01
    相关资源
    最近更新 更多