Search code examples
webwixwindows-installeriis-7.5uninstallation

WIX uninstall doesn't remove site on Windows server 2008 R2


I have installer which setups web site. Installer is implemented using WIX 3.5. The components installing site are in listing below:

  <DirectoryRef Id="TARGETDIR">
    <Directory Id="WWWROOT">
    </Directory>
  </DirectoryRef>

  <Property Id="WWWROOT" Value="C:\inetpub\wwwroot">
    <RegistrySearch Id="FindInetPubFolder" Root="HKLM" Key="SOFTWARE\Microsoft\InetStp" Name="PathWWWRoot" Type="directory" />
  </Property>

  <Component Id="CC_AppPoolConfigure" Guid="YOURGUID-9558-4CAE-A928-EACD27D69A0D" KeyPath="yes" Permanent="no">
    <iis:WebAppPool Id="CC_AppPool" Name="[SITE_APP_POOL]" ManagedRuntimeVersion="v4.0" ManagedPipelineMode="integrated" />
  </Component>

  <Component Id="CC_Iis6SiteConfigure" Guid="YOURGUID-13E2-4980-A55A-E37E3E06FB67" KeyPath="yes" Permanent="no">
    <Condition><![CDATA[Installed OR (IISMAJORVERSION AND (IISMAJORVERSION = "#6"))]]></Condition>
    <iis:WebSite Id="CC_WebSite_IIS6" Description="[SITE_NAME]"
                 AutoStart="yes" StartOnInstall="yes" ConfigureIfExists="yes"
                 Directory="WWWROOT" ConnectionTimeout="360" SiteId="[SITE_ID]">
      <iis:WebVirtualDir Id="CC_Site_IIS6_VDir" Directory="SITE_INSTALLDIR" Alias="[SITE_VIRT_DIR]">
        <iis:WebApplication Id="CC_IIS6_WebApp" Name="[SITE_APP_NAME]" WebAppPool="CC_AppPool"  >
          <iis:WebApplicationExtension Verbs="GET,HEAD,POST" CheckPath="no" Script="yes" Executable="[FRAMEWORKROOT]v4.0.30319\aspnet_isapi.dll" />
        </iis:WebApplication>

        <iis:WebDirProperties Id="CC_Site_IIS6_Properties" WindowsAuthentication="yes" AnonymousAccess="yes"/>
      </iis:WebVirtualDir>

      <iis:WebAddress Id="CC_Site_IIS6_Header_Bindings" Port="[SITE_PORT]" Header="[SITE_HEADER]" />
    </iis:WebSite>
  </Component>

  <Component Id="CC_IIS6_Config_Extentions" Guid="YOURGUID-009A-4545-8D4D-EC5437D7332F" KeyPath="yes" Permanent="yes">
    <Condition><![CDATA[IISMAJORVERSION AND (IISMAJORVERSION = "#6")]]></Condition>
    <iis:WebServiceExtension Id="CC_ExtensionASP4" Group="ASP.NET v4.0.30319" Allow="yes" File="[FRAMEWORKROOT]v4.0.30319\aspnet_isapi.dll" Description="ASP.NET v4.0.30319"/>
  </Component>

  <Component Id="CC_Iis7Site" Guid="YOURGUID-1738-476A-945F-A97721F5ECFC" KeyPath="yes" Permanent="no">
    <Condition><![CDATA[IISMAJORVERSION AND (IISMAJORVERSION >= "#7")]]></Condition>
    <iis:WebSite Id="CC_WebSite_IIS7" Description="[SITE_NAME]"
                 AutoStart="yes" StartOnInstall="yes" ConfigureIfExists="yes"
                 Directory="WWWROOT" ConnectionTimeout="360" SiteId="[SITE_ID]">

      <iis:WebVirtualDir Id="CC_Site_IIS7_VDir" Directory="SITE_INSTALLDIR" Alias="[SITE_VIRT_DIR]">
        <iis:WebApplication Id="CC_IIS7_WebApp" Name="[SITE_APP_NAME]" WebAppPool="CC_AppPool"></iis:WebApplication>

        <iis:WebDirProperties Id="CC_Site_IIS7_Properties" WindowsAuthentication="yes" AnonymousAccess="yes"/>

      </iis:WebVirtualDir>

      <iis:WebAddress Id="CC_Site_IIS7_Header_Binding" Port="[SITE_PORT]" Header="[SITE_HEADER]" />

    </iis:WebSite>
  </Component>

As you can see, site needs to be installed on IIS 6, IIS 7 and IIS 7.5. Installation is fine on all listed environments. Installer performs per-machine installation. I use deffered custom actions for enabling required IIS components etc, so installer first is runned without admin permissions and asks for them when button "Install" is clicked.

But there is a problem uninstalling product using the same installer file which was used to install it - Site and virtual directory left on IIS. It only occurs on Windows Server 2008 R2 (IIS 7.5) when UAC is enabled and only when uninstalling through running installer file and selecting option "Remove" in first dialog. I tested this on few environments (Windows Server 2003, 2003 R2, 2008 x86, 2008 x64, 2008 R2) and it looks like 2008 R2 is the only environment where the issue is present. Other investigations shown that disabling UAC solves the problem. Uninstalling product through control panel or running the same msi from command line with uninstall parameter doesn't have this issue too. So there is very narrow case where issue is present, but it is still important.

I'm almost sure that the problem is because of UAC restrictions: maybe installer tries to uninstall site before UAC dialog is shown to give permissions. But I can't understand how can I fix it. Any help will be appreciated.

If you have better approach to installing site on so various environments, I would be happy to hear it too - my invented wheel probably isn't the best =).

If you need uninstall log, it is here:


Solution

  • We had the same issue and solved it by changing properties that contains Web site and application names to Secure="yes". In your case, make sure that:

    <Property Id="SITE_NAME" Secure="yes">
    <Property Id="SITE_APP_NAME" Secure="yes">