Build WiX 3.6 project targeting x64?

后端 未结 1 385
长情又很酷
长情又很酷 2021-01-31 04:32

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 ava

相关标签:
1条回答
  • 2021-01-31 04:48

    Windows installers cannot be built to target Any CPU, I typically build twice, with the managed code being set to Any CPU, whilst the installer has two configurations x86 and x64.

    You may find you need to create the configurations, this can be done by right clicking on the solution and selecting configuration manager then selecting the drop down under platform. When you're complete you should be able to see the following defined in your 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>
    

    To allow the installer to work with both x86 and x64 define variables to detect and set the architecture of the install.

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

    I append the bitness variable to the name as a visual clue:

    <Product Name="My Install $(var.bitness)"
    

    Refer to the Program Files Folder as appropriate:

      <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Id="$(var.PlatformProgramFilesFolder)">
    

    Components have the Win64 flag set appropriately:

    <Component Win64="$(var.Win64)"
    
    0 讨论(0)
提交回复
热议问题