微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

WixInstaller自定义UI模板不会更改安装路径

如何解决WixInstaller自定义UI模板不会更改安装路径

我在创建自定义UI模板时遇到问题,所需的流程是:

许可证> InstallScope>安装。

我已经获取了WIXUI_Advanced的源代码,并在下面的代码中更改了导航,尽管更改所选范围时,安装路径始终是认安装。

我认为后台正在发生某些事情,尽管我找不到如何注入更改,但所有示例均在下一个导航中完成并加载新页面

Product.wsx

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Product Id="*" Name="$(var.ProductName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="$(var.ProductManufacturer)" UpgradeCode="dd862e01-154d-4840-8d90-1dbb91346b6a">
    <Package InstallerVersion="200" Compressed="yes" />

    <Property Id="ALLUSERS" Value="1" />
    <Property Id="MSIINSTALLPERUSER" Value="1" />
    <Property Id="REINSTALLMODE" Value="amus" />

    <UIRef Id="WixUI_CustomInstaller" />
    <Property Id="ApplicationFolderName" Value="$(var.ProductManufacturer)" />
    <Property Id="WixAppFolder" Value="WixPerMachineFolder" />

    <WixVariable Id="WixUIDialogBmp" Value="$(var.BackgroundImagePath)" />
    <WixVariable Id="WixUIBannerBmp" Value="$(var.BannerImagePath)" />
    <WixVariable Id="WixUILicenseRtf" Value="$(var.LicencePath)" />

    <Icon Id="brandicon.ico" SourceFile="$(var.BrandIconPath)"/>
    <Property Id="ARPPRODUCTICON" Value="brandicon.ico" />

    <MajorUpgrade Schedule="afterInstallInitialize"
                  DowngradeErrorMessage="A newer version of [ProductName] is already installed. Setup will Now exit."
                  AllowSameVersionUpgrades="yes"/>
    <MediaTemplate EmbedCab="yes" />

    <Feature Id="ApplicationFilesFeature" Title="Application Files" Level="1">
      <ComponentGroupRef Id="ApplicationFilesComponents"/>
      <ComponentRef Id="BrandShortcutComponent"/>
      <ComponentRef Id="startmenuShortcutComponent" />
      <ComponentRef Id="DesktopShortcutComponent" />
    </Feature>

    <!-- Add check Box & trigger the custom action if checked -->
    <UI>
      <UIRef Id="WixUI_CustomInstaller" />
      <Publish Dialog="ExitDialog"
               Control="Finish"
               Event="DoAction"
               Value="LaunchApplication">WIXUI_EXITDIAlogoPTIONALCHECKBox = 1 and NOT Installed</Publish>
    </UI>
    <Property Id="WIXUI_EXITDIAlogoPTIONALCHECKBoxTEXT" Value="Launch application" />
    <Property Id="WIXUI_EXITDIAlogoPTIONALCHECKBox" Value="1"/>

    <!-- Custom action for launching application -->
    <Property Id="WixShellExecTarget" Value="[INSTALLFOLDER]Application.exe" />
    <CustomAction Id="LaunchApplication"
                  BinaryKey="WixCA"
                  DllEntry="WixShellExec"
                  Impersonate="yes" />

  </Product>

  <Fragment>
    <!--Application files in LocalHost-->
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="APPLICATIONFOLDER" Name="$(var.ProductManufacturer)">
          <Directory Id="INSTALLFOLDER" Name="$(var.ProductName)">
            <Component Id="BrandShortcutComponent" Guid="8867159f-5160-401d-9e23-841c35db54ec">
              <Shortcut Id="BrandShortcut"
                        Name="$(var.ProductName)"
                        Target="[INSTALLFOLDER]Application.exe"
                        Icon="brandicon.ico"
                        WorkingDirectory="INSTALLFOLDER"/>
              <RegistryValue Root="HKCU" Key="Software\$(var.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
              <util:XmlFile Id='XmlSettings1' File='[INSTALLFOLDER]appSettings.config'
                            Action='setValue' Value='$(var.AuthorityUri)' Name='value' ElementPath="//appSettings/add[\[]@key='authority.uri'[\]]" Sequence='1' />
              <util:XmlFile Id='XmlSettings2' File='[INSTALLFOLDER]appSettings.config'
                            Action='setValue' Value='$(var.MClientId)' Name='value' ElementPath="//appSettings/add[\[]@key='DocumentWorkflow.ClientID'[\]]" Sequence='2' />
              <util:XmlFile Id='XmlSettings3' File='[INSTALLFOLDER]appSettings.config'
                            Action='setValue' Value='$(var.AClientId)' Name='value' ElementPath="//appSettings/add[\[]@key='FileManagement.ClientID'[\]]" Sequence='3' />
              <util:XmlFile Id='XmlSettings4' File='[INSTALLFOLDER]appSettings.config'
                            Action='setValue' Value='$(var.LClientId)' Name='value' ElementPath="//appSettings/add[\[]@key='Analytics.ClientID'[\]]" Sequence='4' />
            </Component>
          </Directory>
        </Directory>
      </Directory>

      <!--Start Menu Links-->
      <Directory Id="ProgramMenuFolder">
        <Component Id="startmenuShortcutComponent" Guid="e8815935-23dc-497e-85d4-f1c2b7fe7208">
          <Shortcut Id="ApplicationstartmenuShortcut"
                    Name="$(var.ProductName)"
                    Target="[INSTALLFOLDER]$(var.ProductName).lnk"
                    Icon="brandicon.ico"
                    WorkingDirectory="INSTALLFOLDER"/>
          <RegistryValue Root="HKCU" Key="Software\$(var.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
        </Component>
      </Directory>

      <!--Desktop Link-->
      <!--IMPORTANT: The component ID must place it after the .lnk shortcut creation. This is why it starts with 'ZZZ' -->
      <Directory Id="DesktopFolder" Name="Desktop">
        <Component Id="DesktopShortcutComponent" Guid="ecb5eebb-a4e0-4218-ad25-d4e77006d8c6">
          <Shortcut Id="ZZZApplicationDesktopShortcut"
                    Name="$(var.ProductName)"
                    Target="[INSTALLFOLDER]$(var.ProductName).lnk"
                    Icon="brandicon.ico"
                    WorkingDirectory="INSTALLFOLDER"/>
          <RemoveFile Id="ApplicationDesktopShortcut" Name="$(var.ProductName)" On="uninstall"/>
          <RegistryValue Root="HKCU" Key="Software\$(var.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
        </Component>
      </Directory>
    </Directory>
  </Fragment>
</Wix>

WixUI_CustomInstaller.wsx

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
    <WixVariable Id="WixUISupportPerUser" Value="1" Overridable="yes" />
    <WixVariable Id="WixUISupportPerMachine" Value="1" Overridable="yes" />
    <PropertyRef Id="ApplicationFolderName" />
    <CustomAction Id="CusWixSetDefaultPerUserFolder" Property="WixPerUserFolder" Value="[LocalAppDataFolder]Apps\[ApplicationFolderName]" Execute="immediate" />
    <CustomAction Id="CusWixSetDefaultPerMachineFolder" Property="WixPerMachineFolder" Value="[ProgramFilesFolder][ApplicationFolderName]" Execute="immediate" />
    <CustomAction Id="CusWixSetPerUserFolder" Property="APPLICATIONFOLDER" Value="[WixPerUserFolder]" Execute="immediate" />
    <CustomAction Id="CusWixSetPerMachineFolder" Property="APPLICATIONFOLDER" Value="[WixPerMachineFolder]" Execute="immediate" />
    <InstallExecuteSequence>
      <Custom Action="CusWixSetDefaultPerUserFolder" Before="CostFinalize" />
      <Custom Action="CusWixSetDefaultPerMachineFolder" After="CusWixSetDefaultPerUserFolder" />
      <Custom Action="CusWixSetPerUserFolder" After="CusWixSetDefaultPerMachineFolder">ACTION="INSTALL" AND APPLICATIONFOLDER="" AND (ALLUSERS="" OR (ALLUSERS=2 AND (NOT Privileged)))</Custom>
      <Custom Action="CusWixSetPerMachineFolder" After="CusWixSetPerUserFolder">ACTION="INSTALL" AND APPLICATIONFOLDER="" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))</Custom>
    </InstallExecuteSequence>
    <InstallUISequence>
      <Custom Action="CusWixSetDefaultPerUserFolder" Before="CostFinalize" />
      <Custom Action="CusWixSetDefaultPerMachineFolder" After="CusWixSetDefaultPerUserFolder" />
      <Custom Action="CusWixSetPerUserFolder" After="CusWixSetDefaultPerMachineFolder">ACTION="INSTALL" AND APPLICATIONFOLDER="" AND (ALLUSERS="" OR (ALLUSERS=2 AND (NOT Privileged)))</Custom>
      <Custom Action="CusWixSetPerMachineFolder" After="CusWixSetPerUserFolder">ACTION="INSTALL" AND APPLICATIONFOLDER="" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))</Custom>
    </InstallUISequence>
    <UI Id="WixUI_CustomInstaller">
      <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="Minimal" />
      <DialogRef Id="ErrorDlg" />
      <DialogRef Id="FatalError" />
      <DialogRef Id="FilesInUse" />
      <DialogRef Id="MsiRMFilesInUse" />
      <DialogRef Id="PrepareDlg" />
      <DialogRef Id="ProgressDlg" />
      <DialogRef Id="ResumeDlg" />
      <DialogRef Id="UserExit" />
      <DialogRef Id="WelcomeDlg" />
      <DialogRef Id="LicenseAgreementDlg"/>
      <DialogRef Id="LInstallScopeDlg" />
      <!-- Below is the navigation flow we will navigate from top to bottom -->
      <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
      <!-- Fresh install -->
      <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>      
      <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="LInstallScopeDlg"></Publish>
      <Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg"></Publish>
      <Publish Dialog="LInstallScopeDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>   
      <Publish Dialog="LInstallScopeDlg" Control="Install" Property="ALLUSERS" Value="1" Order="2">1</Publish>
      <Publish Dialog="LInstallScopeDlg" Control="Install" Property="APPLICATIONFOLDER" Value="[WixPerMachineFolder]" Order="4">1</Publish>
      <Publish Dialog="LInstallScopeDlg" Control="Install" Event="SetTargetPath" Value="WixPerMachineFolder" Order="5">1</Publish>
      <Publish Dialog="LInstallScopeDlg" Control="Install" Event="DoAction" Value="WixUIValidatePath" Order="6">NOT WIXUI_DONTVALIDATEPATH</Publish>
      <Publish Dialog="LInstallScopeDlg" Control="Install" Event="SpawnDialog" Value="InvalidDirDlg" Order="7"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
      <Publish Dialog="LInstallScopeDlg" Control="InstallNoShield" Property="ALLUSERS" Value="{}" Order="1">1</Publish>
      <Publish Dialog="LInstallScopeDlg" Control="InstallNoShield" Property="APPLICATIONFOLDER" Value="[WixPerUserFolder]" Order="3">1</Publish>
      <Publish Dialog="LInstallScopeDlg" Control="InstallNoShield" Event="SetTargetPath" Value="WixPerUserFolder" Order="8">1</Publish>
      <Publish Dialog="LInstallScopeDlg" Control="InstallNoShield" Event="DoAction" Value="WixUIValidatePath" Order="9">NOT WIXUI_DONTVALIDATEPATH</Publish>
      <Publish Dialog="LInstallScopeDlg" Control="InstallNoShield" Event="SpawnDialog" Value="InvalidDirDlg" Order="10"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish> 
      <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
      <!-- Already Installed -->
      <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>
    </UI>
    <UIRef Id="WixUI_Common" />
    </Fragment>
   <Fragment>
        <UI>
            <Dialog Id="LInstallScopeDlg" Width="370" Height="270" Title="!(loc.InstallScopeDlg_Title)" KeepModeless="yes">
                <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallScopeDlgBannerBitmap)" />
                <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
                <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
                <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="20" Transparent="yes" noprefix="yes" Text="!(loc.InstallScopeDlgDescription)" />
                <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" noprefix="yes" Text="!(loc.InstallScopeDlgTitle)" />
                <Control Id="BothScopes" Type="RadioButtonGroup" X="20" Y="55" Width="330" Height="120" Property="WixAppFolder" Hidden="yes">
                    <RadioButtonGroup Property="WixAppFolder">
                        <RadioButton Value="WixPerUserFolder" X="0" Y="0" Width="295" Height="16" Text="!(loc.InstallScopeDlgPerUser)" />
                        <RadioButton Value="WixPerMachineFolder" X="0" Y="60" Width="295" Height="16" Text="!(loc.InstallScopeDlgPerMachine)" />
                    </RadioButtonGroup>
                    <Condition Action="show">Privileged AND (!(wix.WixUISupportPerUser) AND !(wix.WixUISupportPerMachine))</Condition>
                </Control>
                <Control Id="MyPerUserDescription" Type="Text" X="33" Y="70" Width="300" Height="36" Hidden="yes" noprefix="yes" Text="!(loc.InstallScopeDlgPerUserDescription)">
                    <Condition Action="show">!(wix.WixUISupportPerUser)</Condition>
                </Control>
                <Control Id="MynoperUserDescription" Type="Text" X="33" Y="70" Width="300" Height="36" Hidden="yes" noprefix="yes" Text="!(loc.InstallScopeDlgnoperUserDescription)">
                    <Condition Action="show">NOT !(wix.WixUISupportPerUser)</Condition>
                </Control>
                <Control Id="MyPerMachineDescription" Type="Text" X="33" Y="131" Width="300" Height="36" Hidden="yes" noprefix="yes" Text="!(loc.InstallScopeDlgPerMachineDescription)">
                    <Condition Action="show">Privileged</Condition>
                </Control>
                <Control Id="Back" Type="PushButton" X="150" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
                <!--<Control Id="Next" Type="PushButton" X="206" Y="243" Width="56" Height="17" Text="!(loc.WixUINext)" />-->

                <Control Id="Install" Type="PushButton" ElevationShield="yes" X="206" Y="243" Width="80" Height="17" Hidden="yes" Text="!(loc.FeaturesDlginstall)">
                  <Condition Action="show">NOT Installed AND (WixAppFolder = "WixPerMachineFolder")</Condition>
                  <Condition Action="hide">NOT Installed AND (WixAppFolder = "WixPerUserFolder")</Condition>
                  <Condition Action="default">NOT Installed</Condition>
                  <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">!(wix.WixUICostingPopupOptOut) OR CostingComplete = 1</Publish>
                  <Publish Event="EndDialog" Value="Return"><![CDATA[OutOfdiskSpace <> 1]]></Publish>
                  <Publish Event="SpawnDialog" Value="OutOfRbdiskDlg">OutOfdiskSpace = 1 AND OutOfnorbdiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)</Publish>
                  <Publish Event="EndDialog" Value="Return">OutOfdiskSpace = 1 AND OutOfnorbdiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
                  <Publish Event="EnableRollback" Value="False">OutOfdiskSpace = 1 AND OutOfnorbdiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
                  <Publish Event="SpawnDialog" Value="OutOfdiskDlg">(OutOfdiskSpace = 1 AND OutOfnorbdiskSpace = 1) OR (OutOfdiskSpace = 1 AND PROMPTROLLBACKCOST="F")</Publish>
                </Control>

                <Control Id="InstallNoShield" Type="PushButton" ElevationShield="no" X="206" Y="243" Width="80" Height="17" Hidden="yes" Text="!(loc.FeaturesDlginstall)">
                  <Condition Action="show">NOT Installed AND (WixAppFolder = "WixPerUserFolder")</Condition>
                  <Condition Action="hide">NOT Installed AND (WixAppFolder = "WixPerMachineFolder")</Condition>
                  <Condition Action="default">NOT Installed</Condition>
                  <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">!(wix.WixUICostingPopupOptOut) OR CostingComplete = 1</Publish>
                  <Publish Event="EndDialog" Value="Return"><![CDATA[OutOfdiskSpace <> 1]]></Publish>
                  <Publish Event="SpawnDialog" Value="OutOfRbdiskDlg">OutOfdiskSpace = 1 AND OutOfnorbdiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)</Publish>
                  <Publish Event="EndDialog" Value="Return">OutOfdiskSpace = 1 AND OutOfnorbdiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
                  <Publish Event="EnableRollback" Value="False">OutOfdiskSpace = 1 AND OutOfnorbdiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
                  <Publish Event="SpawnDialog" Value="OutOfdiskDlg">(OutOfdiskSpace = 1 AND OutOfnorbdiskSpace = 1) OR (OutOfdiskSpace = 1 AND PROMPTROLLBACKCOST="F")</Publish>
                </Control>

                <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
                    <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
                </Control>
            </Dialog>
        </UI>
    </Fragment>
</Wix>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。