Wix使用UI对话框更改安装路径

时间:2016-01-18 10:36:41

标签: wix windows-installer console-application wix3.5

我正在使用Wix 3.5为控制台应用程序创建.msi。在那,我试图给用户一个选项,使用UI对话框更改安装目录。下面是我的Product.wxs代码:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
  <Product Id="{5E4364D8-DEBA-4615-990C-1C886E569F33}" Name="MeridianAutomationSetUp" Language="1033" Version="1.2.0.0"
           Manufacturer="Meridian Automation" UpgradeCode="d479e1dc-eeff-4c66-a977-04f67f5348ae">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="x86"
              Description="Meridian" Comments="Meridian" InstallPrivileges="elevated"/>

    <MajorUpgrade DowngradeErrorMessage="A newer version of Meridian Automation SetUp is already installed." Schedule="afterInstallInitialize" />
    <MediaTemplate  EmbedCab="yes"/>

    <Feature Id="ProductFeature" Title="Meridian Automation Setup" Level="1">
      <ComponentGroupRef Id="MeridianAutomationSetUp" />
    </Feature>
    <!--<Property Id="TARGETDIR" Value="C:"/>-->
    <PropertyRef Id="NETFRAMEWORK45"/>
    <Condition Message="This application requires .NET Framework 4.5. Please install the .NET Framework 4.5 then run this installer again.">
      <![CDATA[Installed OR NETFRAMEWORK45]]>
    </Condition>
    <UIRef Id="MyUi"/>
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"/>
    <Property Id="WixShellExecTarget" Value="[#MeridianAutomation.exe]" />
    <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="INETPUB">
        <Directory Id="INSTALLDIR" Name="MeridianAutomation1" />
      </Directory>
    </Directory>
  </Fragment>
</Wix>

以下是我的UI代码:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  <copyright file="WixUI_InstallDir.wxs" company="Outercurve Foundation">
    Copyright (c) 2004, Outercurve Foundation.
    This software is released under Microsoft Reciprocal License (MS-RL).
    The license and further copyright text can be found in the file
    LICENSE.TXT at the root directory of the distribution.
  </copyright>
-->

<!--
First-time install dialog sequence:
 - WixUI_WelcomeDlg
 - WixUI_LicenseAgreementDlg
 - WixUI_InstallDirDlg
 - WixUI_VerifyReadyDlg
 - WixUI_DiskCostDlg
Maintenance dialog sequence:
 - WixUI_MaintenanceWelcomeDlg
 - WixUI_MaintenanceTypeDlg
 - WixUI_InstallDirDlg
 - WixUI_VerifyReadyDlg
Patch dialog sequence:
 - WixUI_WelcomeDlg
 - WixUI_VerifyReadyDlg
-->

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <UI Id="MyUi">
      <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
      <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
      <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />

      <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
      <Property Id="WixUI_Mode" Value="InstallDir" />

      <DialogRef Id="BrowseDlg" />
      <DialogRef Id="DiskCostDlg" />
      <DialogRef Id="ErrorDlg" />
      <DialogRef Id="FatalError" />
      <DialogRef Id="FilesInUse" />
      <DialogRef Id="MsiRMFilesInUse" />
      <DialogRef Id="PrepareDlg" />
      <DialogRef Id="ProgressDlg" />
      <DialogRef Id="ResumeDlg" />
      <DialogRef Id="UserExit" />

      <Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish>
      <Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>

      <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication" Order="999">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>

      <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg">NOT Installed</Publish>
      <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>

      <!--<Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
      <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg">LicenseAccepted = "1"</Publish>-->

      <Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
      <Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
      <Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
      <Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
      <Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
      <Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
      <Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>

      <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg" Order="1">NOT Installed</Publish>
      <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH</Publish>
      <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">Installed AND PATCH</Publish>

      <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>

      <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
      <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
      <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>

      <Property Id="ARPNOMODIFY" Value="1" />
      <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch Meridian Automation" />
    </UI>

    <UIRef Id="WixUI_Common" />
  </Fragment>
</Wix>

但是当我更改路径时,它仍然会将应用程序安装在默认安装驱动器中,即C驱动器。我在网上搜索这个,但仍面临同样的问题。

0 个答案:

没有答案