I had a similar requirement, but not exactly. In my case
- config file was getting generated instead of being installed (it's more
like "data" file rather than config file)
- we needed to keep the file mandatorily during an upgrade/repair, but
remove it on uninstall.

Since it was a generated file, the major  upgrade would not uninstall as
there was no associated component.
However, major upgrade or repair would internally uninstall first and then
install the new package. This uninstall step would either delete everything
(if our components were defined so), including the data file, or not delete
non-component file, meaning the data file. As a result, either the data
file will get deleted on upgrade/repair or remain behind despite an
uninstall.

My solution:
- Have a component that creates a folder using CreateFolder. This component
*does* get uninstalled on uninstall, upgrade, repair. Don't remember if I
found a way to configure the component to not delete the folder on
upgrade/uninstall, but delete on uninstall.
- Configure our app to write the file inside this data folder.
- Write a custom action to delete the data folder
- Sequence the custom action for uninstall, but not for upgrade/repair.

I suspect there is/should be a better way to achieve this...

Sameer


2012/2/8 Alexander Krivács Schrøder <alexander.schro...@mermaid.no>

> I have an installer that installs a configuration file, like so:
>
> <Feature Id="AppName.Feature" Title="Application Name" Level="1">
>  <Feature Id="AppConfig.Feature" Level="1" Display="hidden">
>    <Component Id="AppConfig.Component"
> Guid="{E56D54A5-0646-4D0C-9F95-73F82E293705}" Directory="INSTALLLOCATION">
>      <File Source="$(var.AppName.TargetPath).config" />
>    </Component>
>    <Condition Level="0">KEEP_EXISTING_CONFIG = 1 AND
> APPCONFIGEXISTS</Condition>
> </Feature>
> ...
> </Feature>
>
> The APPCONFIGEXISTS is brought out like so:
>
>
>
> <!-- Check for existing application configuration file -->
>
> <Property Id="APPCONFIGEXISTS" >
>
>  <DirectorySearch Id="CheckAppConfigDir" Path="INSTALLDIR" Depth="0">
>
>    <FileSearch Id="CheckAppConfigFile"
> Name="$(var.AppName.TargetFileName).config" />
>
>  </DirectorySearch>
>
> </Property>
>
> The KEEP_EXISTING_CONFIG is a command-line variable, sent in to
> msiexec.exe.
>
> This configuration alone does not do the trick (obviously, since I'm
> asking here) as the configuration file is removed by the next version of
> the MSI before it starts its installation. The Component element has a
> "Permanent" property, but with that one enabled, it certainly does not
> behave as expected (does not get removed on uninstall, never gets replaced
> on upgrade, regardless of what the value of KEEP_EXISTING_CONFIG is).
>
> Any ideas?
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> WiX-users mailing list
> WiX-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wix-users
>
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to