开发者

Wix How do Directories work?

I'm trying to build a WIX installer, which allows the user to specify the install path through command line arguments.

<Property Id="IISROOTPATH">
   <RegistrySearch Id="FindInetPubFolder" Root="HKLM" Key="SOFTWARE\Microsoft\InetStp" Name="PathWWWRoot" Type="directory" />
</Property>    
...
<Directory Id="TARGETDIR" Name="SourceDir">
   <Directory Id="IISROOTPATH">
      <Directory Id="INSTALLPATH" Name="WebsiteFolder">
...

If the user doesn't pass in any arguments, it will look up registry for the iisroot folder, and install the files under a folder called "WebsiteFolder"

But in order for the user to change the install path, they must pass in an absolute path eg

INSTALLPATH="C:\InetPub\wwwroot\CustomWebsiteFolder"
  1. How does this work? does it then ignore the other Directory elements TARGETDIR and IISROOTPATH?

  2. How can I change INSTALLPATH to just WEBSITEFOLDERNAME so the user is only required to pass in the folder name rather than the absolute install 开发者_Python百科path. Thus forcing the user to always install into inetpub?


You should understand the Directory table - the MSI concept behind the Directory element. The best explanation I've ever met is a set of Rob's articles (the link is to the part 1, there are 6 parts, if I remember correctly).


To answer your second question:

  1. Create a custom dialog (Removing the normal folder chooser dialog) where they user can type in the desired folder saving to a property (i.e. [FOLDER_NAME]).
  2. Have a Directory element that is just a placeholder for the folder name.
  3. Attach a custom action to the "Next" button on the dialog created in 1. which sets the Directory from [FOLDER_NAME].
    <Directory Id="IISROOTPATH">
        <Directory Id="INSTALLPATH" Name="WebsiteFolder">        
        </Directory>
    </Directory>
<CustomAction Id="SetFolderPath" Directory="INSTALLPATH" Value="[IISROOTPATH][FOLDER_NAME]" />

Obviously it'll be a good idea to add conditions to the Next button so that the user doesn't use the default or leave the folder name blank.

This will then allow you to keep the root dir as C:\Intetpub\wwwroot and allow them to specify a custom folder.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜