Wix安装程序-基于属性创建文件夹层次结构 [英] Wix Installer - Create Folder hierarchy based on Property

查看:102
本文介绍了Wix安装程序-基于属性创建文件夹层次结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Wix 3.6 创建设置.我仍在学习中.那里的信息仍然零散.我只是在等我的《 Wix开发人员指南》问世.

I am using Wix 3.6 to create a setup. I am still learning as I go along. The information out there is still scattered around. I am just waiting for my Wix Developer Guide book arriving.

我目前有一个自定义UI对话框,用户可以在其中输入一些应用程序配置.该配置的一部分是指定日志文件夹.目前,这仅设置了一个属性[LogFolder].默认为D:\ Logs.

I currently have a custom UI dialog where the user enters some application configuration. Part of that configuration is to specify a log folder. This at present this just sets a property [LogFolder]. This is defaulted to something like D:\Logs.

我希望安装程序在运行安装程序时创建该目录.我可以尝试以下操作,但是在运行安装程序时,它只是在D:驱动器上创建了一个名为[LOGFOLDER]的文件夹.

I want the installer to create that directory when the setup is run. I have the following to try and do this but it just created a folder named [LOGFOLDER] on the D: drive when I run the setup.

<Product ...
    <Directory Id="TARGETDIR" Name="SourceDir" >
        <Directory Id="LogFolderDir" Name="[LOGFOLDER]" >
            <Component Id="LogFolderComponent" Guid="{7E7D6916-B321-40D6-ABAD-696B57A6E5FB}" KeyPath="yes">
                <CreateFolder />
            </Component>
        </Directory>
    </Directory>
    ...
</Product>

如何使用Wix做到这一点?

How can I do this with Wix?

推荐答案

第一步是创建一个设置为所需值的属性:

The first step is create a property set to the value you want:

<Product>
  <Property Id="LOGFOLDER" Value="D:\Logs" />
</Product>

第二步是创建一个对话框,您可以在其中设置此属性(或通过其他方式更改其值):

The second step is to create a dialog where you set this property (or another thing to change its value):

<Dialog>
  <Control Id="Edit_LogFolder" Type="Edit" Property="LOGFOLDER" />
</Dialog>

然后,您需要更改目录结构以在默认位置创建此文件夹:

Then you need to change your directories structure to create this folder in a default location:

<Directory Id="ProgramFilesFolder">
  <Directory Id="INSTALLFOLDER" Name="MyApp">

    <Directory Id="LOGFOLDER" Name="Logs" />

  </Directory>
</Directory>

最后一步是创建一个将创建目录的Component,如下所示:

The last step is to create a Component that will create the directory, like this:

<ComponentGroup Id="ComponentGroup_LogFolder">
  <Component Id="Component_LogFolder" Guid="" Directory="LOGFOLDER">

    <CreateFolder Directory="LOGFOLDER" />

  </Component>
</ComponentGroup>

备注:

如果D:\是光盘驱动器,并且您插入了光盘,则安装将失败,因为它会尝试创建文件夹,但不会成功.

If D:\ is a disc drive and you have a disc inserted, the installation will fail because it will try to create the folder and it won't succeed.

这篇关于Wix安装程序-基于属性创建文件夹层次结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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