31

My solution is built with platform setting "Any CPU". For my WiX 3.6 installer project settings, it seems that I can't set the target platform to "x64"; only "x86" is available. Can the WiX project be built targeting x64?

4

1 回答 1

47

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)"
于 2013-09-05T08:02:02.787 回答