当应用程序为64位时,Wix Toolset不会在64位“程序文件”文件夹中安装WPF应用程序

问题描述

环境:
Visual Studio 2019
Wix工具集-最新
WPF .Net Framework 4.8
Dev OS-Windows 10 Pro 64位

https://github.com/rodsantest1/programfiles64installer

我已将Project的平台设置为x64,并将Wix中的文件夹设置为ProgramFiles64Folder,但它仍在继续安装到Program Files (x86)。我想念什么?

<?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

解决方法

Candle.exe (-arch):WiX显然可以为您处理此问题,而无需为每个组件进行硬编码的平台属性:

  • 1) 将-arch开关传递到 candle.exe 命令行或
  • 2) InstallerPlatform 中设置 .wixproj MSBuild project 属性。

x64 指定为 -arch candle.exe ,会将组件自动设置为64位(无需硬编码)。

对于64位软件包中的任何32位组件,请设置 Win64='no' (如果您编译安装程序的32位版本,则也可以使用)。


也许尝试将 Win64="yes" attribute 添加到您的组件(前提是它们是64位组件),然后添加 x64 as platform (在WiX下使用简化的标记,see here-向下滚动到标记图):

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

<..>

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

执行此操作后,请确保测试所有32位C#自定义操作。我似乎想起了一些陷阱。我现在记得的一切-恐怕。请测试。


链接