How to Upload a File in Stereo Format on Wix

In my previous post I created a WIX installer with the WizWix. The downside is that you lot demand to add all the references by manus. And when new references are added you need to know this before you can build the installer.

In the WixDemo project I have added 3 new class libraries and an image. The course libraries are added as reference and the image is set to Content

image image

In the previous postal service I started with WizWix wizard. But now I want the project output to be added automatically to the Installer:

Adding Binaries with the Heat Harvest Tool

Add a pre build event to harvest all binaries from the project output of the WixDemo projection. This is done by the Heat Harvest Tool.

call            "C:\Program Files (x86)\WiX Toolset v3.vii\bin\heat.exe"            
dir "$(TargetDir)." -var var.WixDemo.TargetDir -dr APPLICATIONFOLDER
-cg Binaries -ag -scom -sreg -sfrag –srd
-o "$(SolutionDir)Installer\$(ProjectName).Binaries.wxs"

This will create a wixdemo.binaries.wxs file which y'all can add as a Link in your installer project.

image

The WixDemo.Binaries.wxs holds all binaries from the WixDemo output directory:

image

In the installer directory we now need to alter the Features.wxs file. In the file a Fragment is added which references to the Binaries department in our WixDemo.Binaries.wxs

image

When y'all build the installer project at this point you will get all kind of ICE30 errors. The trouble is that the WixDemo.exe exists in the Binder.wxs and in the WixDemo.Binaries.wxs.

image

Filter the Binaries file

The Folder.wxs holds the shortcut and folder information for the WixDemo installer. This is something you want to keep. Therefore the WixDemo.exe needs to exist removed from the WixDemo.Binaries.wxs file. Taking a closer look at this file I also want to skip pdb files likewise. This is done past calculation an xslt filter file to the build event.

First add an XSLT Filter file to the installer directory:

image

The Filter holds the following search key's:

<?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">
<xsl:output method="xml" indent="yes" />
<xsl:template match="@*|node()">
<xsl:re-create>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:key proper noun="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" apply="@Id" />
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.xml')]" use="@Id" />
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.dll.config')]" use="@Id" />
<xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.vshost.exe')]" use="@Id" />
<xsl:key proper noun="service-search" match="wix:Component[contains(wix:File/@Source, 'app.confing')]" utilise="@Id" />
<xsl:key name="service-search" match="wix:Component[wix:File/@Source = '$(var.WIXDemo.TargetDir)\WIXDemo.exe']" use="@Id" />
<xsl:template match="wix:Component[key('service-search', @Id)]" />
<xsl:template match="wix:ComponentRef[key('service-search', @Id)]" />
</xsl:stylesheet>

This volition remove all pdb, xml, dll.config, vshost.exe en the WIXDemo.exe file from the Binaries file. In that location is merely 1 thing we need to add extra to the oestrus pre build event:

-t            "$(SolutionDir)Installer\Filter.xslt"          

The consummate pre build event for the binaries is now:

call            "C:\Plan Files (x86)\WiX Toolset v3.7\bin\estrus.exe"            dir            "$(TargetDir)."            -t            "$(SolutionDir)Installer\Filter.xslt"            -var var.WIXDemo.TargetDir -dr APPLICATIONFOLDER -cg Binaries -ag -scom -sreg -sfrag -srd -o            "$(SolutionDir)Installer\$(ProjectName).Binaries.wxs"          

After building the installer the WixDemo.Binaries.wxs file looks like this:

image

Installing the MSI will testify that the binaries and exe are placed in the install directory:

image

Adding Content

Finally I the content (image) needs to exist installed equally well. Add the following line to the pre build event:

call            "C:\Plan Files (x86)\WiX Toolset v3.vii\bin\heat.exe"            project            "$(ProjectPath)"            -directoryid APPLICATIONFOLDER -pog Content -ag -scom -sreg -sfrag -o            "$(SolutionDir)Installer\$(ProjectName).Content.wxs"          

This will create an WixDemo.Content.wxs file you will demand to Add together As Link to your Install Project.

image

All yous need to practise now is add the WIXDemo.Content to the Fragment in the Characteristic.wxs file:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<FeatureGroup Id="CompleteFeatures">
<Feature Id="Complete" Level="i">
<ComponentGroupRef Id="ProductComponents"/>
<ComponentRef Id="ProgramMenuDir" />
<ComponentRef Id="CMP_WIXDemo" />
</Characteristic>
</FeatureGroup>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="APPLICATIONFOLDER">
<ComponentGroupRef Id="Binaries"/>
<ComponentGroupRef Id="WIXDemo.Content"/>
</ComponentGroup>
</Fragment>
</Wix>

Later on installing this new installer yous will see the resource directory and image in the installation directory:

image image

Conclusion

Now you take best of both worlds. A squeamish WIX installer structure with Characteristic, Folder and Production wxs files all created in the commencement place past the WizWix. And next to that you do not need to worry almost adding references and content to your installer. This is washed by the Heat Harvesting Tool. The project and source code can be found on CodePlex!

howardnink1993.blogspot.com

Source: https://ahordijk.wordpress.com/2013/03/26/automatically-add-references-and-content-to-the-wix-installer/

0 Response to "How to Upload a File in Stereo Format on Wix"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel