2

Property change from the UI disappears from uninstall log.

If I install my app with default property values and then run uninstall the property appears in the uninstall log.

If I change the property value from the UI on uninstall it does not appear in the log.

This is the reason why the apppool and webapp remain in IIS after uninstall, which is not the case with the default values.

<Property Id="WEB_APP_NAME" Value="WebApp" Secure="yes" />

this is how to property looks like.

This is where I add it a value from the UI control

    <Control Id="PoolNameEdit"
             Type="Edit"
             X="100"
             Y="45"
             Width="160"
             Height="17"
             Property="WEB_APP_NAME"
             Text="{80}"
             Indirect="no" />

And this is how I use it

<!-- Define the directory structure -->
  <Fragment>

    <!--Directory elemens hierarchy always starts with Id="TARGETDIR" Name="SourceDir"-->
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="WEB_APP_FOLDER_LOC" Name="WebInstaller">
        <Directory Id="WEBFOLDER" Name ="[WEB_APP_NAME]" />
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>

    <!--Concatenate user input for folderpath-->
    <SetDirectory Id="WEBFOLDER"
                  Value="[WEB_APP_FOLDER_LOC][WEB_APP_NAME]"
                  Sequence="both" />

    <!--Create new folder-->
    <DirectoryRef Id="WEBFOLDER">
      <Component Id="cmp_WebDir"
                 Guid="{E0CE5051-1419-4997-949F-020BC814ECDA}"
                 KeyPath="yes">
        <CreateFolder />
      </Component>
    </DirectoryRef>

    <!--Components-->
    <ComponentGroup Id="ProductComponents" Directory="WEBFOLDER">

      <!--Client config-->
      <Component Id="cmpWebConfig"
                 Guid="{1C84DF1F-2EA4-46E6-8125-C6FD410AFED9}"
                 KeyPath="yes">
        <Condition>INCLUDECONFIGFILE="1"</Condition>
        <File Source="Configuration\Web.config" />
      </Component>

      <!--Application pool-->
      <Component Id="cmpAppPool"
                 Guid="{00D6ABB1-734F-4788-ADB8-12A30056C513}"
                 KeyPath="yes">

        <iis:WebAppPool Id="MyAppPool"
                        Name="[WEB_APP_NAME]"
                        ManagedRuntimeVersion="v4.0"
                        ManagedPipelineMode="integrated"
                        Identity="applicationPoolIdentity" />
      </Component>

      <!--Website-->
      <Component Id="cmpMyWebsite"
                 Guid="{ECD42015-C067-44F3-94D9-5E713BCB586D}"
                 KeyPath="yes">

        <iis:WebSite Id="website_MyWebsite"
                     Description="[WEB_APP_NAME]"
                     Directory="WEBFOLDER"
                     ConfigureIfExists="no">

          <iis:WebApplication Id="webapplication_MyWebsite"
                              Name="[WEB_APP_NAME]"
                              WebAppPool="MyAppPool" />

          <iis:WebAddress Id="webaddress_MyWebsite"
                          Port="[WEB_APP_PORT]" />
        </iis:WebSite>
      </Component>

I would have expected after the change of WEB_APP_NAME in the UI, the uninstaller to be able to find it and thus remove appool and webapp from IIS.

Property(S): VirtualMemory = 3353
Property(S): UpgradeCode = {A4F9CA9E-4135-4D6F-AF58-FADA49E265DA}
Property(S): ConfigureIIs7Exec = **********
Property(S): StartIIS7ConfigTransaction = **********
Property(S): RollbackIIS7ConfigTransaction = **********
Property(S): CommitIIS7ConfigTransaction = **********
Property(S): WriteIIS7ConfigChanges = **********
Property(S): NETFRAMEWORK45 = #461808
Property(S): WEBFOLDER= C:\inetpub\WebApp\
Property(S): WEB_APP_FOLDER_LOC = C:\inetpub\
Property(S): WEB_APP_NAME = WebApp
Property(S): WEB_APP_PORT = 8080
Property(S): WEB_APP_USERNAME = ******
Property(S): WEB_APP_DOMAIN_NAME = ******
Property(S): WEB_APP_SQLSERVER_NAME = ******
Property(S): INCLUDECONFIGFILE = 1

this is how the default uninstall log looks like, if I change WEB_APP_NAME to something else, WEB_APP_NAME is not found on the uninstall log where it can be seen above?

Appreciate any ideas that would resolve this!

Kris
  • 322
  • 8
  • 19
  • AFAIR you can't change a folder of a component during an uninstallation since all these folders are cached. – montonero Feb 15 '19 at 14:30
  • The folders and files inside are removed successfuly, however, the appool and website name are not. The difference between uninstalling default and not-default insall is that property `WEB_APP_NAME` that's missing from the uninstall log after not-default install, hence I am thinkin this is the problem just because on default uninstall the property is there...? So why it gets removed is what I am after? Or the question is how to cache that property properly? – Kris Feb 15 '19 at 14:45
  • What is happening in the log at the moment of the property's value assignment? – montonero Feb 15 '19 at 14:56
  • `MSI (c) (DC:F4) [15:49:24:244]: PROPERTY CHANGE: Modifying WEB_APP_NAME property. Its current value is 'WebApp'. Its new value: 'WebsiteName'.` same happens at [15:49:37] and then it gets listed at the bottom of the install log. – Kris Feb 15 '19 at 15:53
  • I can see the property now in the uninstall log, however it has the default value `Property(S): WEB_APP_NAME = WebApp`. So it looks like the change hasn't been registered? – Kris Feb 15 '19 at 15:55
  • I have done another test, and any of the properties I have changed from the gui does not appear to be changed in the uninstall log, only the [WEBFOLDER] seems to have changed? How do I force properties to change? – Kris Feb 15 '19 at 16:12
  • Can't look at this right now. Lobbing you a link off the top of my head, please skim this: [**Persisting MSI Properties**](https://stackoverflow.com/a/48652032/129130). – Stein Åsmul Feb 15 '19 at 16:28
  • Does publishing of properties has something to do with that? Thanks I will check the link – Kris Feb 15 '19 at 16:31
  • Looks like I've completely missed the point. I thought, that the property was changed through UI during the uninstall. This phrase confused me `If I change the property value from the UI on uninstall it does not appear in the log`. – montonero Feb 16 '19 at 16:08
  • Sorry, fair to say I have missed a comma there, but yes I meant properties set from UI on install, aren't kept, so uninstall uses default values, hope that makes more sense. I still cannot understand why UI won't override the default ones, to wherever they are stored. – Kris Feb 16 '19 at 17:32
  • In this case the answer from Isaiah4110 is correct. Windows Installer doesn't store properties. If you need this value - store it somewhere and then read upon uninstall. – montonero Feb 16 '19 at 22:38

2 Answers2

4

The key thing to understand here is that Windows Installer does not save Property values. The user entered values (either through UI or through command line arguments) will not be available during repair, upgrade or uninstall. You would imagine, it to be available during uninstall that's a simple ask, but that's the way windows installer works. The most simple solution to bypass this is to read the property and then write it to registry. During repair/uninstall/upgrade do a RegistrySearch and use the value based on what's in registry.

As to why the default value is retained during uninstall, That’s because the initial/default value gets added to the MSI Property table. And that same value gets used from the property table during uninstall as well.

Isaiah4110
  • 9,855
  • 1
  • 40
  • 56
  • 2
    And [**Rob Mensching's remember pattern**](http://robmensching.com/blog/posts/2010/5/2/the-wix-toolsets-remember-property-pattern/) can be used for this purpose. [Sample](https://stackoverflow.com/a/48652032/129130). I am wondering if he is allowing the name to be changed in the uninstall GUI though - that would not be good. Not quite clear from the writing. – Stein Åsmul Feb 15 '19 at 23:07
  • But why everything happens as expected with predefined (hardcoded) property values? And when I change them from UI or cmd.. they are only valid at that point. I also have a "summary" dialog that lists the property values to check and verify before proceeding with installation and they look alright at that point.. but back to default values on uninstall..? Still cannot understand what controls that.. – Kris Feb 15 '19 at 23:32
  • So there's no way to update the MSI Property table from UI? So if the initial prop values are added what happens to their changes, just get discarded? This seem so weird?! – Kris Feb 16 '19 at 09:34
  • The initial value is added when we create the Msi, that’s when the property table for that msi gets created. I have told you the problem and the solution. Writing the registry would take just few lines of code. And you also need to read more about MSI, windows installer to understand basics. – Isaiah4110 Feb 16 '19 at 12:03
  • @SteinÅsmul if you could add your comment as an answer, I will mark it. Thank you all for the help, I was supper stubborn to accept this is the only way, as it still doesn't seem logical to me, but after I make the properties persistent it all work as I wanted it and I am super pleased.. Thank you! – Kris Feb 16 '19 at 20:20
  • Added the answer as requested. Hope it is clear. Isaiah4110's answer is good as well. Please see the section on installation mode. – Stein Åsmul Feb 16 '19 at 23:47
  • I just read Rob's blog, that makes sense totally. My solution was just a work around, adding the custom action makes the value persist in the property table itself. Thats much cleaner. That should be the answer! Thank you @SteinÅsmul for that link. Kris thank you for your persistence, I learnt something new as well! :) – Isaiah4110 Feb 17 '19 at 00:17
2

Note: Please prevent the properties from being changeable during uninstall at least. I think you should only accept changes during fresh install? Or major upgrade? Otherwise the resolved directory name does not match the installed one (same problem you originally had).

Persist Properties: You need to persist the relevant properties when you allow them to be shown and changed in your setup GUI or via command line. Otherwise the properties will be blank when resolved as directory or application names - or whatever capacity you use them for in your setup. Persisting MSI properties is not a built-in Windows Installer feature (just a few system-properties are automatically persisted). Generally an MSI anti-pattern, but that is how it is.

"Remember Pattern" Sample: For regular, PUBLIC properties (UPPERCASE properties) you can use Rob Mensching's remember pattern to save and retrieve property values for repair, modify, uninstall and other maintenance operations. There is a small sample of this property persistence pattern in use here: WIX UI for multiple target directories (Remember Pattern in use).

Installation Modes: There are many installation modes to check when you make a setup: fresh install, repair, modify, self-repair, uninstall, major upgrade uninstall, patching, rollback, resume suspended (reboot and other causes), etc... I would test at least the first 6 types - to make sure resolution works properly.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164