【发布时间】:2025-12-11 12:05:01
【问题描述】:
我的解决方案是使用平台设置“任何 CPU”构建的。对于我的WiX 3.6 安装程序项目设置,似乎无法将目标平台设置为“x64”;只有“x86”可用。可以针对 x64 构建 WiX 项目吗?
【问题讨论】:
标签: wix
我的解决方案是使用平台设置“任何 CPU”构建的。对于我的WiX 3.6 安装程序项目设置,似乎无法将目标平台设置为“x64”;只有“x86”可用。可以针对 x64 构建 WiX 项目吗?
【问题讨论】:
标签: wix
Windows 安装程序无法针对任何 CPU 构建,我通常构建两次,托管代码设置为任何 CPU,而安装程序具有 x86 和 x64 两种配置。
您可能会发现需要创建配置,这可以通过右键单击解决方案并选择配置管理器然后选择平台下的下拉菜单来完成。完成后,您应该能够在 wixproj 中看到以下定义:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DefineConstants>Debug</DefineConstants>
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
为了让安装程序同时使用 x86 和 x64 定义变量来检测和设置安装架构。
<?if $(var.Platform) = x64 ?>
<?define bitness = "(64 bit)" ?>
<?define Win64 = "yes" ?>
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
<?else ?>
<?define bitness = "(32 bit)" ?>
<?define Win64 = "no" ?>
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
<?endif ?>
我将bitness 变量附加到名称作为视觉线索:
<Product Name="My Install $(var.bitness)"
酌情参考Program Files文件夹:
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.PlatformProgramFilesFolder)">
组件的 Win64 标志设置得当:
<Component Win64="$(var.Win64)"
【讨论】: