1

Environment:
Visual Studio 2019
Wix Toolset - latest
WPF .Net Framework 4.8
Dev OS - Windows 10 Pro 64-bit

https://github.com/rodsantest1/programfiles64installer

I've set Platform for project to x64 and set folder in Wix to ProgramFiles64Folder but it keeps installing to Program Files (x86). What am I missing?

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"><?define WpfApp1_TargetDir=$(var.WpfApp1.TargetDir)?>
    <Product Id="*" Name="SetupProject1" Language="1033" Version="1.0.0.0" Manufacturer="RCS" UpgradeCode="68c32f22-6310-415f-abb5-2027e3825dfc">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate EmbedCab="yes" CompressionLevel="high" />

        <Feature Id="ProductFeature" Title="SetupProject1" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFiles64Folder">
                <Directory Id="INSTALLFOLDER" Name="SetupProject1" />
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <Component Id="WpfApp1.exe" Guid="7cb2f935-47b4-4df8-9112-742b3f6c8569">
              <File Id="WpfApp1.exe" Name="WpfApp1.exe" Source="$(var.WpfApp1_TargetDir)WpfApp1.exe" />
            </Component>
            <Component Id="WpfApp1.exe.config" Guid="66fdfbdd-5089-4fc9-9742-30a0d914b738">
              <File Id="WpfApp1.exe.config" Name="WpfApp1.exe.config" Source="$(var.WpfApp1_TargetDir)WpfApp1.exe.config" />
            </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

enter image description here

Rod
  • 14,529
  • 31
  • 118
  • 230

1 Answers1

2

Candle.exe (-arch): WiX can apparently handle this for you without hard-coded platform attribute for each component:

  • 1) Pass the -arch switch to candle.exe command line or
  • 2) Set the InstallerPlatform property in a .wixproj MSBuild project.

Specify x64 as -arch and candle.exe will auto-set the components to 64-bit (no hard coding needed).

For any 32-bit components in the 64-bit package, set Win64='no' (also works if you compile a 32-bit version of the setup).


Maybe try to add the Win64="yes" attribute to your components (provided they are 64-bit components) and add x64 as platform (below WiX using simplified markup, see here - scroll down to the markup illustration):

<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="x64" />

<..>

<Component Feature="ProductFeature" Win64="yes">
   <File Source="C:\Windows\Notepad.exe" />
</Component>

Make sure to test any 32-bit C# custom actions after doing so. I seem to recollect some bear traps. All I remember right now - I am afraid. Please test.


Links:

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • That worked but I have a lot of files, do I manually have to add that to each component? I suppose I can do a search and replace, but.... – Rod Sep 24 '20 at 14:25
  • How many components do you have? [There is always XSLT](https://github.com/mitea1/mixxxdj/blob/7e39c207d93154bf02f9afa85235234702986466/build/wix/only-dll.xslt) - not that I have much experience with it ([XSLT - Wikipedia](https://en.wikipedia.org/wiki/XSLT)). – Stein Åsmul Sep 24 '20 at 18:39
  • [One more XSLT sample](https://stackoverflow.com/questions/8034798/wix-installer-using-xslt-with-heat-exe-to-update-attributes) (not mine). – Stein Åsmul Sep 24 '20 at 19:32
  • Around 600 components – Rod Sep 24 '20 at 20:44
  • Completely unnecessary: http://www.joyofsetup.com/2010/05/14/working-hard-or-hardly-working/ – Bob Arnson Sep 24 '20 at 20:46
  • I knew there was something missing here: *"Or, just let WiX handle it for you: Specify the -arch switch at the candle.exe command line or the InstallerPlatform property in a .wixproj MSBuild project. When you specify x64 or intel64, Candle automatically sets the package and components in the file being compiled as 64-bit. It’s still useful to be able to say Win64='no' for those components that are 32-bit even in 64-bit packages. Of course, that’s also legal in 32-bit packages, so it’s safe to hard-code."* – Stein Åsmul Sep 25 '20 at 00:13
  • Are you saying the 600 components for installer is completely unnecessary? It's all the dependencies though. Where do I specify the InstallerPlatform property in setup project? – Rod Sep 25 '20 at 00:20