使用WiX,如何更改虚拟目录的子文件夹的属性?

时间:2010-05-31 20:19:15

标签: iis wix windows-installer wix3

我在WiX脚本中有一个目录元素的层次结构。

我还有一个创建虚拟目录的组件(使用IIS:WebVirtualDir),它指向我的目录层次结构的根目录。

如何更改虚拟目录的子文件夹的属性(例如AnonymousAccess),例如

MyVirtualDir<<<这是虚拟目录根

MyVirtualDir \ MySubFolder<<<这是我希望使用WebDirProperties

更改属性的子文件夹

请注意,我希望为子文件夹创建新的虚拟目录。我只想更改一些安全设置。

当前脚本太大,无法在此发布,但请查看WiX教程:5.3 Web Directory。假设在该示例中,有另一个名为“MySubFolder”的Directory元素嵌套在“InstallDir”元素中。然后,为了设置“MySubFolder”的属性而不将其转换为虚拟目录,下一步将是什么?

1 个答案:

答案 0 :(得分:3)

IIS的示例代码:Web元素似乎很难获得,但经过一些试验和错误后,我认为我找到了一个解决方案:

在目录层次结构中正常创建文件夹:

<Directory Id='blahDir' Name='blah'>
    <Component Id ='CreateBlah' Guid='B1976E1A-DEB1-4FBB-A5AB-4AA60930D2DC'>
        <CreateFolder />
    </Component>
</Directory>

创建一个IIS:WebDirProperties元素(在本例中,是一些用于测试的随机值):

<IIS:WebDirProperties Id="ReadAndExecute" Read="yes" Write="yes" Script="yes" Execute="yes" AnonymousAccess="yes" Index="no" LogVisits="no" />

创建指向文件夹和WebDirProperties元素的IIS:WebDir组件:

<Component Id='TestWebDir' Guid='8ED05357-1AAE-49F2-8C66-8813583C8157'>
    <IIS:WebDir WebSite='DefaultWebSite' Id='MyWebDir' Path='Test/blah' DirProperties='ReadAndExecute' />
</Component>

整个样本,改编自WiX教程,可以在下面找到:

<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:IIS="http://schemas.microsoft.com/wix/IIsExtension">
    <Product Name='Foobar 1.0' Id='48A3DF7A-E1C3-48BE-91D9-4D7368740A78' UpgradeCode='F8ABBBC9-0696-4FA9-A0DC-C9368E858A76'
      Language='1033' Codepage='1252' Version='1.0.0' Manufacturer='Acme Ltd.'>

        <Package Id='*' Keywords='Installer'
          Description="Acme's Foobar 1.0 Installer"
          Comments='Foobar is a registered trademark of Acme Ltd.' Manufacturer='Acme Ltd.'
          InstallerVersion='100' Languages='1033' Compressed='yes' SummaryCodepage='1252' />

        <Icon Id="AddRemoveProgram.ico" SourceFile="AddRemoveProgram.ico" />
        <Property Id="ARPPRODUCTICON" Value="AddRemoveProgram.ico" />

        <Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
        <Property Id='DiskPrompt' Value="Acme's Foobar 1.0 Installation [1]" />

        <Directory Id='TARGETDIR' Name='SourceDir'>
            <Directory Id='ProgramFilesFolder' Name='PFiles'>
                <Directory Id='InstallDir' Name='Acme'>

                    <Directory Id='blahDir' Name='blah'>
                        <Component Id ='CreateBlah' Guid='B1976E1A-DEB1-4FBB-A5AB-4AA60930D2DC'>
                            <CreateFolder />
                        </Component>
                    </Directory>

                    <Component Id='default.htmlComponent' Guid='E2FC2FC2-96A2-4BE5-BBCB-7184D9AAACA0'>
                        <File Id='default.htmFile' Name='default.htm' KeyPath='yes' DiskId='1' Source='default.htm' />
                    </Component>

                </Directory>
            </Directory>

            <Component Id='TestWebVirtualDirComponent' Guid='B4E73F80-875C-487A-BC57-A568732F03A3'>
                <IIS:WebVirtualDir Id='TestWebVirtualDir' Alias='Test' Directory='InstallDir' WebSite='DefaultWebSite'>
                    <IIS:WebApplication Id='TestWebApplication' Name='Test' />
                </IIS:WebVirtualDir>
            </Component>

            <Component Id='TestWebDir' Guid='8ED05357-1AAE-49F2-8C66-8813583C8157'>
                <IIS:WebDir WebSite='DefaultWebSite' Id='MyWebDir' Path='Test/blah' DirProperties='ReadAndExecute' />
            </Component>

        </Directory>

        <IIS:WebSite Id='DefaultWebSite' Description='Default Web Site'>
            <IIS:WebAddress Id='AllUnassigned' Port='80' />
        </IIS:WebSite>

        <Feature Id='TestFeature' Title='TestFeature' Level='1'>
            <ComponentRef Id='CreateBlah'/>
            <ComponentRef Id='default.htmlComponent' />
            <ComponentRef Id='TestWebDir'/>
            <ComponentRef Id='TestWebVirtualDirComponent' />
        </Feature>

        <IIS:WebDirProperties Id="ReadAndExecute" Read="yes" Write="yes" Script="yes" Execute="yes" AnonymousAccess="yes" Index="no" LogVisits="no" />

    </Product>
</Wix>