【发布时间】:2014-05-22 06:45:06
【问题描述】:
我正在尝试为 x86 和 x64 创建一个安装程序(一个 MSI 文件)。我希望安装过程只安装基于目标机器平台的相关文件。 到目前为止,我只有一个适用于 x86 的 MSI,它按预期工作。 现在我添加了这个部分:
<!-- Details to support both x86 and x64 platforms-->
<?if $(var.Platform) = x64 ?>
<?define ProductName = "MyApp (64 bit)" ?>
<?define Win64 = "yes" ?>
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
<?define ExportReleaseComponentGroup = "Export64ReleaseComponentGroup" ?>
<?define MyApplication = "$(var.x64SourcePath)\MyApp.exe" ?>
<?else ?>
<?define ProductName = "MyApp" ?>
<?define Win64 = "no" ?>
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
<?define ExportReleaseComponentGroup = "Export32ReleaseComponentGroup" ?>
<?define MyApplication = "$(var.win32SourcePath)\MyApp.exe" ?>
<?endif ?>
现在我遇到了一些错误:
-
在 x64 机器中,它安装在 Program Files (x86) 文件夹下。我正在 x86 中编译 SetupProject,这可能是原因吗?相关代码:
<Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="$(var.PlatformProgramFilesFolder)"> -
安装结束时应用程序不运行。相关代码:
<!--CA to launch the exe after install--> <Property Id="WixShellExecTarget" Value="$(var.MyApplication)" /> <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" /> -
未创建桌面快捷方式和开始菜单快捷方式。相关代码:
<Component Id="ProgramFilesShortcut" Guid="{My-Guid}"> <Condition>MY_DESKTOP_SHORTCUT</Condition> <Shortcut Id="desktopMyApp" Directory="DesktopFolder" Name="MyApp" Target="$(var.MyApplication)" WorkingDirectory="bin" Icon="MyIcon.ico"> </Shortcut> <RemoveFolder Id="ProgramFilesShortcut" On="uninstall" /> <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Name="installed" Type="integer" Value="1" KeyPath="yes" /> </Component> <Component Id="ProgramMenuDir" Guid="{My-Guid}"> <Shortcut Id="startmenuMyApp" Directory="ProgramMenuFolder" Name="MyApp" Target="$(var.MyApplication)" Icon="MyIcon.ico" WorkingDirectory="bin" Arguments="-s"> <!-- Set the AppID in order to get toasts to work --> <ShortcutProperty Key="System.AppUserModel.ID" Value="MyCompany.MyApp" /> </Shortcut> <RemoveFolder Id="ProgramMenuDir" On="uninstall" /> <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Name="installed" Type="integer" Value="1" KeyPath="yes" /> </Component>
知道我做错了什么吗?
【问题讨论】: