[wix-users] Keep Harvested File on Uninstall
Todd Hoatson
todd.hoatson at gmail.com
Mon Jun 10 15:15:57 PDT 2019
Thanks, Rob & Christopher, for your helpful responses.
For now, to mark harvested components as 'permanent', I am using the
following xslt (based on a post I found on StackOverflow):
-------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
xmlns="http://schemas.microsoft.com/wix/2006/wi"
exclude-result-prefixes="wix">
<xsl:template match="wix:Wix">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="wix:Component">
<!-- Just copy the tag itself -->
<xsl:copy>
<!-- Copy all attributes -->
<xsl:apply-templates select="@*" />
<!-- Here we will add the Permanent-attribute to all components
-->
<xsl:attribute name="Permanent">yes</xsl:attribute>
<!-- Now take the rest of the inner tag -->
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
-------------------------
This marks all components as permanent for a particular invocation of
heat.exe. In order to mark a specific component, we could have used:
-------------------------
...
<xsl:template match="wix:Component">
<!-- Just copy the tag itself -->
<xsl:copy>
<!-- Copy all attributes -->
<xsl:apply-templates select="@*" />
<!-- Here comes the distinction: if you find our special
component, do some special things -->
<xsl:choose>
<!-- Note that the string is translated to all lower case,
so you don't have to care about being case sensitive or not -->
<xsl:when test="@Id = 'usfm.sty'">
<!-- Here we will add the Permanent-attribute to this
very special component -->
<xsl:attribute name="Permanent">yes</xsl:attribute>
</xsl:when>
</xsl:choose>
<!-- Now take the rest of the inner tag -->
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
...
-------------------------
But I sure wish there were simply an option on heat.exe (-mp, perhaps?) to
mark components as permanent... or, better yet, a way to refer to
components harvested by heat from within my WiX code and add additional
attributes to them.
On the whole, I find the documentation of the 'permanent' attribute (and
component attributes in general) pretty sparse and unhelpful.
But I'm thankful for this forum, and the helpful responses.
Todd
On Sun, Jun 9, 2019 at 11:13 PM Rob Mensching <rob at firegiant.com> wrote:
> If using heat.exe, an XSLT is how you solve this problem.
>
> We (at FireGiant) developed a more advanced harvesting solution (
> https://www.firegiant.com/wix/wep-documentation/harvesting/). We very
> recently implemented a feature in that I believe does exactly what you
> want. Something like:
>
> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
> xmlns:fg="http://www.firegiant.com/schemas/v3/wxs/fgwep.xsd">
> <Fragment>
> <ComponentGroup Id="ContentComponents">
> <Component Directory="ContentFolder" Permanent="yes">
> <fg:HarvestFolder Source="path\to\content\**" />
> </Component>
> </ComponentGroup>
> </Fragment>
> </Wix>
>
> If you want to try it out, you could grab a trial license (
> https://www.firegiant.com/products/wix-expansion-pack/) and contact
> "support at firegiant dot com" to get access to the build with this
> additional functionality. Tell them I sent you. <smile/>
>
> _____________________________________________________________
> Short replies here. Complete answers over there:
> http://www.firegiant.com/
>
>
> -----Original Message-----
> From: wix-users <wix-users-bounces at lists.wixtoolset.org> On Behalf Of
> Todd Hoatson via wix-users
> Sent: Thursday, June 6, 2019 2:14 PM
> To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
> Cc: Todd Hoatson <todd.hoatson at gmail.com>
> Subject: [wix-users] Keep Harvested File on Uninstall
>
> Hi all,
> our installer installs a pre-set data folder for the user's data, which
> includes some default style sheets & settings of various kinds. We harvest
> these files using the heat utility and then reference the component group
> in our main WiX file.
>
> On uninstall, we don't want any files in the data folder to be
> uninstalled. The user may simply be uninstalling & reinstalling to correct
> some other problem, and then they would lose all their settings.
>
> Is there a way to mark as "permanent" these components or a component
> group that is the result of a harvesting operation?
>
> I saw this StackOverflow article:
>
> https://stackoverflow.com/questions/22418172/wix-keep-file-harvested-by-heat-on-uninstall-or-upgrade
>
>
> Is the use of an xslt file the only way to do this? Or is it possible
> to tag the component / component group as permanent within my main WiX code?
>
> I see that heat accepts a "template"n argument, but I don't know where
> to look for more information about this or if it would even help...
>
> thanks,
> Todd Hoatson
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
>
--
Todd Hoatson
Mobile: 763-291-3312
Email: todd.hoatson at gmail.com
www.linkedin.com/in/toddhoatson
More information about the wix-users
mailing list