1

I use the following Wix code to create a WebApplication in IIS and assign it to a specific Application Pool.

<iis:WebAppPool Id="AppPool_Wcf" Name="$(var.WCF_APP_POOL)" />

<iis:WebSite Id="Web_site" Description="$(var.WEB_SITE_DESCRIPTION)" SiteId="[SITEID]">
    <iis:WebAddress Id="Web_Address" Port="*"/>
</iis:WebSite>

<DirectoryRef Id="TARGETDIR">
    <Directory Id="SITEPATH">
        <Directory Id="WCF_VIRT_DIR" Name="$(var.WCF_VIRT_DIR)">
            <Component Id="IIS_Wcf" Guid="$(var.deploy.wcf.guid)" KeyPath="yes">
                <iis:WebVirtualDir Id="Wcf_VirtualDir" Alias="$(var.WCF_VIRT_DIR)" WebSite="Web_site" Directory="WCF_VIRT_DIR">
                    <iis:WebApplication Id="Wcf_Application" Name="$(var.WCF_VIRT_DIR)" WebAppPool="AppPool_Wcf" />
                </iis:WebVirtualDir>
            </Component>
        </Directory>
    </Directory>
</DirectoryRef>

App Pool should already exist, as it’s shared with some other applications.

If it doesn’t exist, setup succeeds, assigning Web Application to a mysterious <Invalid Application Pool> (can be seen in web app Properties). The application even works!

How can I make installation fail if App Pool is not found?

1 Answer 1

0

You have to create an immediate custom action for this. For instance, in C#/DTF it could be implemented like this:

[CustomAction]
public static ActionResult FailIfAppPoolNotExist(Session session)
{
  DirectoryEntry appPool = new DirectoryEntry(string.Format("IIS://localhost/w3svc/AppPools/{0}", session["APP_POOL_NAME"]));

  if (appPool == null)
  {
    return ActionResult.Failure;
  }
  return ActionResult.Success;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.