OK.  I'll construct a transform, but this seems like a daunting task.

I always have to run heat after every check out.  The developers can
change anything over time, branches, and releases, and the build isn't
supposed to break, so the smoothest policy for me is to limit
assumptions by always running heat against what ever is present.

I couldn't figure out how to modify the Component in the heat generated
file, so my transform chops it out, and I manually create the Component
in another file, with file associations.  This seems to be the easiest
way to solve the problem and I don't have to be an xslt wizard.

First, my Product element contains:
<Feature Id='Complete' Level='1'>
  <!-- Pull in file association -->
  <ComponentRef Id="FileAssociations" />
</Feature>
<!-- Directory Structure -->
<Directory Id="TARGETDIR" Name="SourceDir" >
  <Directory Id="ProgramFilesFolder" Name="Pfiles" >
    <Directory Id="MYPRODUCTSDIR" Name="$(var.MyCompanyNameShort)" >
      <Directory Id="INSTALLDIR" Name="$(var.MyProductName) $(var.Version)" >
      </Directory>
    </Directory>
  </Directory>
</Directory>

Second, another .wxs file contains the Component for my exe and file
associations:
<Fragment>
  <DirectoryRef Id="INSTALLDIR">
    <Component 
      Id="FileAssociations"
      Guid="$(var.Guid_ProgramFile)"
    >
      <File 
        Id="MainExeFile" 
        KeyPath="yes" 
        Source="$(var.dist)\foo.exe" 
      />
      <!-- associate .fooProject file extension with foo.exe -->
      <ProgId 
        Id="fooProject" 
        Description="Foo Project"
      >
        <Extension Id="galileoGlobalProject" >
          <Verb 
            Id="open" 
            TargetFile="MainExeFile" 
            Argument="&quot;%1&quot;" 
          />
        </Extension>
      </ProgId>
    </Component>
  </DirectoryRef>
</Fragment>

My xslt transformation file cuts out the exe Component from the 
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
        xmlns:wix="http://schemas.microsoft.com/wix/2006/wi";>
  <!-- strip out the exe files from the fragment heat generates. -->
  <xsl:template match="@*|*">
        <xsl:copy>
          <xsl:apply-templates select="@*|node()" />
        </xsl:copy>
  </xsl:template>
  <xsl:output method="xml" indent="yes" />
  <xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, 
'foo.exe')]" use="@Id" />
  <xsl:template match="wix:Component[key('exe-search', @Id)]" />
  <xsl:template match="wix:ComponentRef[key('exe-search', @Id)]" />
</xsl:stylesheet>


Commands:

heat.exe dir dist -dr INSTALLDIR -cg group_ProductFiles -gg -g1 -sf -srd -var 
env.dist -t .\wix_project\MyProgram.filter2.xsl -out 
.\wix_project\MyProgram.resource_list.wxs 

candle.exe -dwxi_variables=MyProgram.variables.wxi -i MyProgram.variables.wxi 
-v -arch x86 -trace -out wixobj/ .\wix_project\MyProgram.wxs 
.\wix_project\MyProgram.resource_list.wxs .\wix_project\MyProgram.shortcuts.wxs 

light.exe -out foo.msi -b dist -ext WixUIExtension wixobj/MyProgram.wixobj 
wixobj/MyProgram.resource_list.wixobj wixobj/MyProgram.shortcuts.wixobj 

And it all worked.

I think the documentation could really benefit from a practical example
like this, so people don't have to search though the mailing list
threads.

On Thu, 2013-08-15 at 16:27 -0700, Blair Murri wrote:
> That's why I use a transform to insert the file association code under the 
> file element and I don't harvest my icons.
> 
> To ne fair, harvesting was originally intended to be performed just once, not 
> each build. Most projects don't need to be harvested each time, but there are 
> systems that do require it.
> 
> 
> "jo...@msli.com" <jo...@msli.com> wrote:
> 
> If heat generates a file with unique identifiers for each element, is it
> true that the Id of a particular element can't be referenced elsewhere,
> as there is no way to determine the correct name?
> 
> I am facing this situation by trying to create a file association, where
> my exe has an Id that changes every time I run heat, yet creating a file
> association requires a TargetFile and Icon that refer to an Id, and not
> the name of the file it self.
> 
> The following is a file association, but the '?' are the areas of
> interest:
> <ProgId Id="galileoGlobalProject" Description="Galileo Global Project" 
> Icon="?" IconIndex="0" >
>   <Extension Id="galileoGlobalProject" >
>     <Verb Command="Open" Id="open" TargetFile="?" Argument="&quot;%1&quot;" />
>   </Extension>
> </ProgId>
> 
> A hack is calling heat.exe with argument -suid, which sets the Id = file
> name, and I simply use the file name in TargetFile="file_name.exe", but
> it has issues if two files have the same name in different areas (i
> think).
> 
> Since heat is part of wix it seems like in the design of how all the
> parts fit together there must be a better way.
> 
> 
> NOTICE: This email may contain confidential information.  Please see 
> http://www.meyersound.com/confidential/ for our complete policy.
> 
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite!
> It's a free troubleshooting tool designed for production.
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
> _______________________________________________
> WiX-users mailing list
> WiX-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wix-users
> 
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite!
> It's a free troubleshooting tool designed for production.
> Get down to code-level detail for bottlenecks, with <2% overhead. 
> Download for free and get started troubleshooting in minutes. 
> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
> _______________________________________________
> WiX-users mailing list
> WiX-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wix-users



------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to