当应用程序是 64 位时,Wix 工具集不会在 64 位程序文件文件夹中安装 WPF 应用程序

Wix Toolset won't install WPF app in 64-bit Program Files Folder when the app is 64-bit

环境:
Visual Studio 2019
Wix 工具集 - 最新
WPF .Net Framework 4.8
开发 OS - Windows 10 专业版 64 位

https://github.com/rodsantest1/programfiles64installer

我已将项目平台设置为 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>

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).


也许可以尝试将 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# 自定义操作。我似乎想起了一些熊陷阱。我现在只记得 - 我很害怕。请测试。


链接: