多个目标目录的 WIX UI [英] WIX UI for multiple target directories

查看:23
本文介绍了多个目标目录的 WIX UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用户能够为我的安装设置多个不同的目标目录.

I need the User to be able to set multiple different target directories for my installation.

我有这个目录结构:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="DCOMPANY" Name="MyCompany" >
      <Directory Id="DMAIN" Name="MainDir">
        <Directory Id="DPART1" Name="Part1"/>
        <Directory Id="DPART2" Name="Part2"/>
      </Directory>
    </Directory>
  </Directory>
</Directory>

我这里也有这些属性

<Property Id="WIXUI_INSTALLPATH" Hidden="yes" /> 
<Property Id="VARIABLE_PATH_DPART1" Value="DPART1" />
<Property Id="VARIABLE_PATH_DPART2" Value="DPART2" />

为了覆盖 Single InstallDirDialog,我复制了 WIXUI_InstallDir.wxs 和 InstallDirDlg.wxs 文件.我复制了 InstallDirDlg.wxs 并将数字 1 和 2 添加到文件的末尾,在所有三个前面加上 custom_ 并相应地更改了它们的 UI 标签:

To override the Single InstallDirDialog, I've copied the files WIXUI_InstallDir.wxs and InstallDirDlg.wxs. I duplicated InstallDirDlg.wxs and added the numbers 1 and 2 to the end of the files, prefixed all of the three with custom_ and changed their UI-Tags correspondingly:

现在,在 custom_WIXUI_InstallDir.wxs 中,我对这个块做了一些更改,所以我希望我的属性是由操作设置的:

Now, in the custom_WIXUI_InstallDir.wxs, theres this block that I changed a little so I would expect MY Properties are being set by the Actions:

  <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="custom_InstallDirDlg1">LicenseAccepted = "1"</Publish>


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

  <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog"
  Value="custom_InstallDirDlg1" Order="1">NOT Installed</Publish>

在 custom_InstallDirDlg1.wxs 中,我也将此行更改为我的路径变量:

In custom_InstallDirDlg1.wxs I also changed this line to my path variable:

    <Control Id="Folder" Type="PathEdit" X="20" Y="100" Width="320"
  Height="18" Property="VARIABLE_PATH_DPART1" Indirect="yes" />

当我现在编译时,一切都会被创建,当我运行安装程序时,当我点击更改..."按钮或下一步..."按钮时,安装程​​序会冻结大约 30 秒,然后说指定的路径 DPART1 不可用."

When I compile now, everything gets created and when I run the Installer, when I click on the "Change..." Button or the "Next..." button the Installer freezes for approximately 30 seconds and then Says "The specified Path DPART1 is unavailable."

当我查看在所有这些 CDATA 块中调用的自定义操作的来源时,我看到那些只关心 WIXUI_INSTALLPATH 并且不接受给予他们的任何东西.所以它几乎使用了间接.

When I look at the sources of the custom actions that are being called in all those CDATA blocks I see that those only ever care for the WIXUI_INSTALLPATH and don't accept anything given to them. So it's pretty much using indirection for that.

我还在某处读到可以重用此对话框来让用户输入多个目标路径,但我不知道如何操作.

I've also read somewhere that this dialog can be reused to have the User enter multiple target paths but I can't figure out how.

请帮忙:)

推荐答案

也许我会将其添加为答案,以便您可以像您说的那样接受它 - 并且可能会赞成.然后让赏金用完 - 我认为它不会起作用,因为你还没有声誉.

Maybe I will add it as an answer so you can accept it like you say - and maybe upvote. Then just let the bounty run out - I don't think it will work since you don't have the reputation yet.

我目前没有时间详细阅读此内容,但请查看此答案:WiX-installer使用可配置功能目录(朝向中间,如果看起来相关,还有答案的其余部分).这些是功能目录",可以链接到链接中描述的实际目录属性.

I don't have time to read this in detail at the moment, but please have a look at this answer: WiX-installer With Configurable Feature Directory (towards the middle, and also the rest of the answer if it looks relevant). These are "feature directories" that can be linked to an actual directory property as described in the link.

以上示例使用 WiX Mondo 对话框集.我描述了使用此处设置的 Mondo 对话框设置最小 WiX 编译.本质上是一个Hello WiX"项目,但您已经完成了.只是添加它以防其他人可能会发现它有帮助.

The sample above uses the WiX Mondo dialog set. I describe setting up a minimal WiX compile with the Mondo dialog set here. Essentially a "Hello WiX" project, but you have this down already. Just adding it in case someone else may find it helpful.

更新:我的简短测试似乎表明,对于大多数安装模式,系统会保留此类功能目录,但对于主要升级则不会.要读取这些自定义文件夹的先前设置,您需要 AppSearch 或我想说的自定义操作,并且您应该使您的设置在注册表中保留目录属性.

UPDATE: My brief testing seems to show that such feature directories are persisted by the system for most installation modes, but not for major upgrades. To read the previous settings for these custom folders, you need either an AppSearch or a custom action I'd say, and you should make your setup persist the directory properties in the registry.

这些只是来自快速测试的一些建议.请像往常一样,彻底测试自己.Windows Installer 中有很多我称之为阴谋复杂性"的东西 - 问题出乎意料地出现 - 例如,当您尝试提供升级时.

These are just some suggestions from quick testing. Please, as always, test thoroughly yourself. There is a lot of what I call "conspiratory complexity" in Windows Installer - problems surface unexpectedly - for example when you try to deliver an upgrade.

在安装过程中将您的属性保留在注册表中(您的功能目录属性):

Persisting your properties in the registry during install (your feature directory properties):

<!--Put this inside a component-->
<RegistryKey Root="HKLM" Key="Software\MyCompany\MyApp" ForceCreateOnInstall="yes">
  <RegistryValue Type="string" Name="MYCUSTOMDIR" Value="[MYCUSTOMDIR]" KeyPath="yes"/>
</RegistryKey>

<!--Put this inside a component-->
<RegistryKey Root="HKLM" Key="Software\MyCompany\MyApp" ForceCreateOnInstall="yes">
  <RegistryValue Type="string" Name="MYCUSTOMDIRTWO" Value="[MYCUSTOMDIRTWO]" KeyPath="yes"/>
</RegistryKey>

很重要!:这将写入 HKLM\SOFTWARE\WOW6432Node\MyCompany\MyApp - 64 位操作系统上注册表的 32 位部分.您可能需要从 64 位部分写入和读取.如果是这样,只需将 Win64="yes" 属性添加到组件和 RegistrySearch 元素.

And important!: this will write to HKLM\SOFTWARE\WOW6432Node\MyCompany\MyApp - the 32-bit section of the registry on a 64-bit OS. You may need to write and read from the 64-bit section. If so, just add the Win64="yes" attribute to the Components and the RegistrySearch elements.

链接:http://robmensching.com/blog/posts/2010/5/2/the-wix-toolsets-remember-property-pattern/

接下来通过注册表搜索将它们读回:

<Property Id="MYCUSTOMDIR">
  <RegistrySearch Id='MYCUSTOMDIR' Root='HKLM' Key='Software\MyCompany\MyApp' Name='MYCUSTOMDIR' Type='raw' />
</Property>

<Property Id="MYCUSTOMDIRTWO">
  <RegistrySearch Id='MYCUSTOMDIRTWO' Root='HKLM' Key='Software\MyCompany\MyApp' Name='MYCUSTOMDIRTWO' Type='raw' />
</Property>    

在理想的世界中,这应该足以满足您的目的.我没有时间测试在命令行中为升级设置这些属性时会发生什么(可能会发生).

In an ideal world this should suffice for your purpose. I did not have time to test what happens when these properties are set at the command line for an upgrade (which could happen).

要创建用于测试的重大升级,您基本上只需增加版本号的前三位数字之一并编译一个新的 MSI(重命名输出文件夹中的旧 MSI 以保留它) - 并生成一个新的产品 G​​UID(除非您将其设置为自动生成,在这种情况下版本凹凸就足够了).为了符合 MSI 标准,MSI 版本号应该只有 3 位数字.

To create a major upgrade for testing you can basically just bump up one of the first three digits of your version number and compile a new MSI (rename the old MSI in the output folder to preserve it) - and generate a new product GUID (unless you have it set to auto-generate, in which case the version bump is enough). An MSI version number should incidentally have only 3 digits to be compliant to MSI standards.

这篇关于多个目标目录的 WIX UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆