0

我正在尝试让我正在编写的安装程序安装 Visual C++ 2012 包,这样最终用户就不必单独进行了。

可执行文件位于安装目录中,但是当我构建安装程序时,我收到一条错误消息,指出系统找不到该文件。

这是与我的安装程序部分相关的代码块。如果有多个错误,请提前道歉。我刚刚开始接触 WiX。

<Binary Id="MyVC" SourceFile="[INSTALLDIR]vcredist_x64.exe"/>
<CustomAction   Id='VCInstall'
                BinaryKey="MyVC"
                ExeCommand='/quiet'
                Execute='deferred' 
                Return='ignore'/>

<InstallExecuteSequence>
    <Custom Action="VCInstall" Before="InstallFinalize" ></Custom>
</InstallExecuteSequence>
4

2 回答 2

1

如果您不想使用引导程序,最好的方法是通过合并模块。为了让您做您想做的事,您必须使用自定义操作从二进制文件中提取数据并将其写入目标计算机上某个位置的新文件,然后运行设置 - 这不遵循 MSI 最佳实践。但是,如果您想走这条路,我可以帮助您。这就是我将它们添加到我的项目中的方式,并在安装过程中安装它们InstallExecuteSequence

    <!-- Including the 64-bit redistributables if the platform is 64-bit -->
<?if $(var.Platform) = x64 ?>
<DirectoryRef Id="TARGETDIR">
  <Merge Id="Microsoft_VC110_CRT_x64" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC110_CRT_x64.msm" Language="0" DiskId="1"/>
  <Merge Id="Microsoft_VC110_ATL_x64" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC110_ATL_x64.msm" Language="0" DiskId="1"/>
  <Merge Id="Microsoft_VC110_MFC_x64" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC110_MFC_x64.msm" Language="0" DiskId="1"/>
  <Merge Id="Microsoft_VC110_MFCLOC_x64" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC110_MFCLOC_x64.msm" Language="0" DiskId="1"/>
</DirectoryRef>

<Feature Id="VCRedistx64" Display="hidden" Level="1">
  <MergeRef Id="Microsoft_VC110_CRT_x64"/>
  <MergeRef Id="Microsoft_VC110_ATL_x64"/>
  <MergeRef Id="Microsoft_VC110_MFC_x64"/>
  <MergeRef Id="Microsoft_VC110_MFCLOC_x64"/>
</Feature>
<?endif ?>

<!--Installing 32-bit Visual C++ 2012 Redistributables-->
<?if $(var.Platform) = x86 ?>
<DirectoryRef Id="TARGETDIR">
  <Merge Id="Microsoft_VC110_CRT_x86" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC110_CRT_x86.msm" Language="0" DiskId="1"/>
  <Merge Id="Microsoft_VC110_ATL_x86" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC110_ATL_x86.msm" Language="0" DiskId="1"/>
  <Merge Id="Microsoft_VC110_MFC_x86" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC110_MFC_x86.msm" Language="0" DiskId="1"/>
  <Merge Id="Microsoft_VC110_MFCLOC_x86" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC110_MFCLOC_x86.msm" Language="0" DiskId="1"/>
</DirectoryRef>

<Feature Id="VCRedist" Display="hidden" Level="1">
  <MergeRef Id="Microsoft_VC110_CRT_x86"/>
  <MergeRef Id="Microsoft_VC110_ATL_x86"/>
  <MergeRef Id="Microsoft_VC110_MFC_x86"/>
  <MergeRef Id="Microsoft_VC110_MFCLOC_x86"/>
</Feature>
<?endif ?>
于 2013-01-17T14:12:29.433 回答
0

Here is a complete example installer for a Qt5 application that includes the VC redistributables as a merge module, which might provide a good starting point.

于 2013-11-13T08:05:30.477 回答