21

I'm building an installer at the moment that targets just 64bit machines. Part of the process involves running Heat.exe to produce a Fragment elements containing part of the deployed application.

The problem is the components that are produced by heat produce ICE:80 errors which is WiX complaining that the components target 32bit systems and my installer is trying to load these into:

<Directory Id="ProgramFiles64Folder">

Looking at the documentation there is a -platform switch that can be used to tell Heat that we are targeting an x64 environment however there is no clue in the documentation on how to use this switch. I've tried:

-platform=x64

-platform=Win64

Nothing seems to effect the output in order to set the Win64 attribute on the generated components. Has anyone figured this out? Or am I barking up the wrong tree entirely?

If I manually edit the harvested components to add Win64="yes" the ICE error goes away.

In my <Product> element I have Platform="x64" as I understand it candle should take this and work out that the components should be set to x64 by default but this isn't working it seems.

Very confused.

Jammer
  • 9,969
  • 11
  • 68
  • 115
  • I've gotten this working for now by using the InstallerPlatform property in the `.wixproj` file. This is the same as setting the `-arch` switch on the command line. – Jammer Apr 08 '14 at 10:23
  • What I do normally for such cases: use an XSLT-file on the heat-commandline that will add the `Win64='yes'`-attribute to each component. Even then I always use the `arch`-parameter and the `platform`-property, just to be sure. If you need an appropriate XSLT-file, I will post it in an answer (as a comment is too short). – taffit Apr 11 '14 at 11:28

4 Answers4

23

I also had this problem. Below is what I've done and it helped.

1)

Open .wixproj file in notepad and manually change Condition-s in PropertyGroup-s to be "x64" instead of "x86":

<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
...
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
...
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
...

2)

Go to Configuration Manager for the solution and make sure that x64 is chosen as the platform for the Wix project.

Although Heat still generates Component nodes without Win64="yes", but it builds ok and installs to the C:\Program Files!

Ivan
  • 9,089
  • 4
  • 61
  • 74
21

Here would be the XSLT-file. Save it as e.g. HeatTransform.xslt:

<?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:output method="xml" encoding="UTF-8" indent="yes" />

  <xsl:template match="wix:Wix">
    <xsl:copy>
      <!-- The following enters the directive for adding the config.wxi include file to the dynamically generated file -->
      <!--xsl:processing-instruction name="include">$(sys.CURRENTDIR)wix\config.wxi</xsl:processing-instruction-->
      <xsl:apply-templates select="@*" />
      <xsl:apply-templates />
    </xsl:copy>
  </xsl:template>

  <!-- ### Adding the Win64-attribute to all Components -->
  <xsl:template match="wix:Component">

    <xsl:copy>
      <xsl:apply-templates select="@*" />
        <!-- Adding the Win64-attribute as we have a x64 application -->
        <xsl:attribute name="Win64">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>

Then, in your heat-commandline add the parameter -t <PathToYourFile>\HeatTransform.xslt. This will add the Win64-attribute to every component. Additionally I have Platform='x64'-attribute in my WiX source file(s) and add the -arch x64-parameter to the invocation of candle, as you already described in your question.

taffit
  • 1,979
  • 22
  • 23
6

The documentation of the Package Element and candle task suggests to use the InstallerPlatform property:

Platform

The platform supported by the package. Use of this attribute is discouraged; instead, specify the -arch switch at the candle.exe command line or the InstallerPlatform property in a .wixproj MSBuild project.

InstallerPlatform

Specifies the processor architecture for the package. [...] This is equivalent to the -arch switch in candle.exe.

that is:

<PropertyGroup>
  <InstallerPlatform>x64</InstallerPlatform>
</PropertyGroup>

And for completness: If you want a single WiX-Project for multiple target platforms you should have a look at Platform identification in WiX 3.0.

Micha Wiedenmann
  • 19,979
  • 21
  • 92
  • 137
  • Thanks, simply adding these 3 lines worked for me (` – Aviad P. Aug 19 '19 at 12:22
  • I did this and I see an -arch switch appear in the output, but it still did not work. -arch x86 still writes to the System 64 folder, not System32 :( – john k Jul 01 '21 at 20:27
4

In Visual Studio:

  1. Select Project Properties
  2. Select "Tool Settings" tab
  3. In "Additional parameters (compiler)" type: -arch x64
Jeff McClintock
  • 1,242
  • 10
  • 27