WiX property not found in uninstall log

被刻印的时光 ゝ 提交于 2019-12-13 01:27:43

问题


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!


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/54710379/wix-property-not-found-in-uninstall-log

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!