0

Product.wsx

IISConfiguration

I want to put all posible values, from app pool identity, in wix dropdown. I can't assign the APP_POOL_IDENTITY to Identity property from iis:WebAppPool.

I want to remove constraint for these elements:

The iis:WebAppPool/@Identity attribute's value , '[APP_POOL_IDENTITY]', is not one of the legal options: 'networkService', 'localService', 'localSystem', 'other', or 'applicationPoolIdentity'.

Alex
  • 1,013
  • 1
  • 13
  • 27

1 Answers1

3

This is similar to Can I allow a user to choose either applicationPoolIdentity or specify a user using WiX-IIS extension?, but with a slightly more complicated answer.

Yes, it is possible but you will need to create a component group with each of the possible combinations of xml attributes as components. Each set of components will need their own ID, guid, etc. From your user interface filled out options, you would determine which component to install. As this solution is a bit verbose, I recommend having it in a separate file.

Here is an example for two options that require different attributes, one for custom app pool user, one for applicationPoolIdentity. Use the "CustomUser" component as a template for any further custom options you would need. Note, you only need to specify additional components if the WiX XML would change, not just for changing property values.

Based on https://www.codeproject.com/Articles/115036/Creating-WIX-Installer-for-ASP-NET-Web-Application.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
    <Fragment>
        <Property Id="IIS_WEBSITE" Value="root"/>
        <Property Id="VIRTUAL_DIR_VAL" Value="myappdir" />

        <!-- +++++++++++++++++++ web app name properties initialize ++++++++++++++++++++ -->
        <Property Id="WEB_APP_NAME" Value="myapp" />
        <Property Id="WEB_APP_USE_CUSTOM_APP_POOL_IDENTITY" Value="1" />

        <!-- +++++++++++++++++++ app pool identity properties initialize +++++++++++++++ -->
        <Property Id="WEB_APP_POOL_IDENTITY_DOMAIN" Value="domain" />
        <Property Id="WEB_APP_POOL_IDENTITY_NAME" Value="user" />
        <Property Id="WEB_APP_POOL_IDENTITY_PWD" Hidden="yes" />

        <!-- Reference to IIS Website to install to, but not create -->
        <iis:WebSite Id='rootwebsite'
                 Description='[IIS_WEBSITE]'
                 Directory='INSTALLFOLDER'>
          <!-- This element has to be here or WiX does not compile. It’s ignored 
               in this case. -->
          <iis:WebAddress Id="AllUnassignedHTTP" Port="80" />
          <iis:WebAddress Id="AllUnassignedHTTPS" Port="443" />
        </iis:WebSite>

        <DirectoryRef Id="INSTALLFOLDER">

          <Component Id="InstallWebsiteCustomUser" Guid="[guid]" KeyPath="yes" Win64="yes">
            <Condition><![CDATA[WEB_APP_USE_CUSTOM_APP_POOL_IDENTITY = 1]]></Condition>
            <util:User Id="WebAppPoolUser"
                       CreateUser="no"
                       Name="[WEB_APP_POOL_IDENTITY_NAME]"
                       Password="[WEB_APP_POOL_IDENTITY_PWD]"
                       Domain="[WEB_APP_POOL_IDENTITY_DOMAIN]" />
            <iis:WebAppPool Id="WebAppPoolCustom"
                            Name="[WEB_APP_NAME]"
                            Identity="other"
                            User="WebAppPoolUser"
                            ManagedPipelineMode="Integrated"
                            ManagedRuntimeVersion="v4.0"
                            RecycleMinutes="200" />
            <iis:WebVirtualDir Id="WebVirtualDirCustom"
                               Alias="[VIRTUAL_DIR_VAL]"
                               Directory="INSTALLFOLDER"
                               WebSite="rootwebsite">
              <!-- Turn the Virtual Directory into a web application. -->
              <iis:WebApplication Id="WebApplicationCustom"
                                  Name="[WEB_APP_NAME]"
                                  WebAppPool="WebAppPoolCustom" />
            </iis:WebVirtualDir>
          </Component>

          <Component Id="InstallWebsite" Guid="[guid]" KeyPath="yes" Win64="yes">
            <Condition><![CDATA[WEB_APP_USE_CUSTOM_APP_POOL_IDENTITY <> 1]]></Condition>
            <iis:WebAppPool Id="WebAppPool"
                            Name="[WEB_APP_NAME]"
                            Identity="applicationPoolIdentity"
                            ManagedPipelineMode="Integrated"
                            ManagedRuntimeVersion="v4.0"
                            RecycleMinutes="200"/>
            <iis:WebVirtualDir Id="WebVirtualDir"
                               Alias="[VIRTUAL_DIR_VAL]"
                               Directory="INSTALLFOLDER"
                               WebSite="rootwebsite">
              <!-- Turn the Virtual Directory into a web application. -->
              <iis:WebApplication Id="WebApplication"
                                  Name="[WEB_APP_NAME]"
                                  WebAppPool="WebAppPool" />
            </iis:WebVirtualDir>
          </Component>
        </DirectoryRef>

        <ComponentGroup Id="IisConfiguration">
          <ComponentRef Id="InstallWebsiteCustomUser" />
          <ComponentRef Id="InstallWebsite" />
        </ComponentGroup>
    </Fragment>
</Wix>
BinaryConstruct
  • 191
  • 1
  • 5