开发者

IIS website physical path becomes blank on wix uninstall

开发者 https://www.devze.com 2023-02-05 12:49 出处:网络
Background: I have a Wix installer where a virtual directory gets created in an existing IIS website. The virtual directory is created (it doesn\'t exist before the install) but the IIS website should

Background: I have a Wix installer where a virtual directory gets created in an existing IIS website. The virtual directory is created (it doesn't exist before the install) but the IIS website should already be created (user just 开发者_StackOverflow社区picks a website to install to in a ListBox).

The problem: On uninstall, the Physical Path of the IIS website that got installed to becomes blank, no value for that attribute. Below is a pared down version of my main wix file. I'm not sure why the uninstall is affecting the IIS website, but any thoughts are appreciated.

Notes: I'm on Wix 3.5 and Windows Server 2008 R2, IIS 7.

<Product>

    <Property Id='WEBSITE_DESCRIPTION'>
      <RegistrySearch Id='RememberPropertyWEBSITE_DESCRIPTION' Root='HKCU'
        Key='SOFTWARE\Company\Product' Name='InstalledWebsiteDescription'
        Type='raw' />
    </Property>

    <Property Id='WEBSITE_PORT'>
      <RegistrySearch Id='RememberPropertyWEBSITE_PORT' Root='HKCU'
        Key='SOFTWARE\Company\Product' Name='InstalledWebsitePort'
        Type='raw' />
    </Property>


    <Component Id='PropertiesToSave' Directory='ApplicationFolder'>
      <RegistryValue Root='HKCU' Key='SOFTWARE\Company\Product'
        Name='InstalledWebsiteDescription' Value='[WEBSITE_DESCRIPTION]'
        Type='string' />
      <RegistryValue Root='HKCU' Key='SOFTWARE\Company\Product'
        Name='InstalledWebsitePort' Value='[WEBSITE_PORT]'
        Type='string' />

      <RemoveFolder Id='CleanupApplicationFolder' On='uninstall' />
    </Component>


    <Directory Id='TARGETDIR' Name='SourceDir'>
      <Component Id='TestWebVirtualDirComponent' Guid='12345678-6304-410E-A808-E3585379EADB'>
        <CreateFolder />
        <iis:WebVirtualDir Id='TestWebVirtualDir' Alias='[WEBSITE_VIRTUALDIR]' Directory='TARGETDIR' WebSite='MyWebsite'>
          <iis:WebApplication Id='TestWebApplication' Name='Test' />
        </iis:WebVirtualDir>
      </Component>
    </Directory>

    <iis:WebSite Id="MyWebsite" Description="[WEBSITE_DESCRIPTION]" SiteId="*">
      <iis:WebAddress Id="AllUnassigned" Port="[WEBSITE_PORT]" />
    </iis:WebSite>

    <Feature>
      <ComponentRef Id='TestWebVirtualDirComponent'/>
      <ComponentRef Id='PropertiesToSave'/>
    </Feature>
</Product>


WiX IIsExtension recognizes the WebSite by Description attribute and Port attribute of child WebAddress element. So, when you install your application, you set WEBSITE_DESCRIPTION and WEBSITE_PORT in some way. However, when you run uninstall, the mentioned properties are not set, and you get the behavior you described.

The solution to this is to save the required property values to system registry and use RegistrySearch element to read the values and set appropriate properties. This is called "Remember Property" pattern and is perfectly explained by Rob Mensching here.

0

精彩评论

暂无评论...
验证码 换一张
取 消