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.
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.
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>
Run Code Online (Sandbox Code Playgroud)
How can I do this with Wix?
第一步是创建一个属性设置为您想要的值:
<Product>
<Property Id="LOGFOLDER" Value="D:\Logs" />
</Product>
Run Code Online (Sandbox Code Playgroud)
第二步是创建一个对话框,您可以在其中设置此属性(或其他更改其值的内容):
<Dialog>
<Control Id="Edit_LogFolder" Type="Edit" Property="LOGFOLDER" />
</Dialog>
Run Code Online (Sandbox Code Playgroud)
然后您需要更改目录结构以在默认位置创建此文件夹:
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="MyApp">
<Directory Id="LOGFOLDER" Name="Logs" />
</Directory>
</Directory>
Run Code Online (Sandbox Code Playgroud)
最后一步是创建一个将创建目录的组件,如下所示:
<ComponentGroup Id="ComponentGroup_LogFolder">
<Component Id="Component_LogFolder" Guid="" Directory="LOGFOLDER">
<CreateFolder Directory="LOGFOLDER" />
</Component>
</ComponentGroup>
Run Code Online (Sandbox Code Playgroud)
评论:
如果 D:\ 是磁盘驱动器并且您插入了磁盘,则安装将失败,因为它会尝试创建文件夹并且不会成功。
| 归档时间: |
|
| 查看次数: |
4885 次 |
| 最近记录: |