views:

208

answers:

1

I have a hierarchy of Directory elements in a WiX script.

I also have a component that creates a virtual directory (using IIS:WebVirtualDir), which points to the root of my Directory hierarchy.

How do I change a property (e.g. AnonymousAccess) of a subfolder of the virtual directory, e.g.

MyVirtualDir <<< this is the virtual directory root

MyVirtualDir\MySubFolder <<< this is the subfolder for which I wish to change a property using WebDirProperties

Please note that I do not wish to create a new virtual directory for the subfolder. I only wish to change a few security settings.

The current script is too big to post here, but take a look at the WiX tutorial: 5.3 Web Directory. Suppose in that example that there was another Directory element named "MySubFolder" nested within the "InstallDir" element. What would then be the next step in order to set properties for "MySubFolder" without turning it into a virtual directory?

+1  A: 

Sample code for the IIS:Web element seems to be hard to come by, but after some trial and error, I think I found a solution:

Create the folder as normal in the Directory hierarchy:

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

Create an IIS:WebDirProperties element (in this case, some random values for testing):

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

Create an IIS:WebDir component pointing to the folder and the WebDirProperties element:

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

The entire sample, adapted from the WiX tutorial, can be found below:

<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:IIS="http://schemas.microsoft.com/wix/IIsExtension"&gt;
    <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>
Joergen Bech