WIX 在安装时运行 vcredist_x64.exe [英] WIX run vcredist_x64.exe on install

查看:36
本文介绍了WIX 在安装时运行 vcredist_x64.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 VS 2015 中编译的应用程序,需要 VC++Redistributable 包才能正常运行.在此最新版本之前,我们使用的是旧版本的 VS,并仅使用合并模块来处理适当的 redist 文件的安装.但是,我注意到当使用 2015 年最新版本的合并模块 (Microsoft_VC140_CRT_x64.msm) 时,我的应用程序仍然无法开箱即用.我做了一些挖掘似乎在最新版本的合并模块中有些事情发生了变化.看来微软现在建议直接安装 vcredist_x64.exe 包,而不是使用合并模块.

I have an application compiled in VS 2015 and requires the VC++ Redistributable package in order to run properly. Prior to this latest build, we were using an older version of VS and simply used a merge module to handle the installation of the appropriate redist files. However, I noticed that when using the latest version of the merge modules for 2015 (Microsoft_VC140_CRT_x64.msm) that my application still wouldn't work out of the box. I did some digging and it appears that some things have changed with the latest version of the merge modules. It appears that Microsoft is now recommending to install the vcredist_x64.exe package directly instead of using merge modules.

所以,我正在尝试创建一个自定义操作来执行此操作.我正在关注 类似的教程在这里,尽管对其进行了调整VC 可再发行可执行文件.我需要做的第一件事是设置 .exe 文件在安装后的位置:

So, I'm attempting to create a custom action to do this. I'm following a similar tutorial here, although adapting it for the VC Redistributable executable. The first thing I need to do is setup where the .exe file is going to be placed once installed:

<Directory Id='APPLICATIONROOTDIRECTORY' Name='MyApp'>
  <Directory Id="VCREDISTDIR" Name="VCRedist">
  </Directory>
</Directory>

然后,我需要将我的文件添加到一个组件组中,该组将作为隐藏功能的一部分安装(因为我希望它自动安装).

Then, I need to add my files into a component group which will be installed as part of a hidden feature (as I want this to be automatically installed).

<ComponentGroup Id="VCRedist" Directory="VCREDISTDIR">
  <Component Id="vcredist_x64.exe" Guid="-INSERT-GUID-HERE-" Win64="yes">
    <File Id="VCREDISEXE" Name="vcredist_x64.exe" KeyPath="yes" Source="$(var.VCRedistSourceDir)" Checksum="yes"></File>
  </Component>
</ComponentGroup>

还有……

<Feature Id="VCRedistributable" Title="Visual C++ Runtime" AllowAdvertise="no" Display="hidden" Level="1">
  <ComponentGroupRef Id="VCRedist" />
</Feature>

此时应将 vcredist_x64.exe 复制到最终用户的机器上.现在,我需要创建一个自定义操作来在安装后启动可执行文件.

At this point, the vcredist_x64.exe should be copied to the end user's machine. Now, I need to create a custom action to launch the executable after the installation.

<CustomAction Id="InstallVCRedistributable"
          FileKey="VCREDISEXE"
          Execute="deferred"
          ExeCommand="/silent"
          Impersonate="no"
          Return="check"/>

<InstallExecuteSequence>
  <Custom Action="InstallVCRedistributable" Before="InstallFinalize">
    <![CDATA[NOT REMOVE]]>
  </Custom>
</InstallExecuteSequence>

我还在 UI 中包含了一条状态消息,以便我可以看到可执行文件的执行时间.

I also include a status message to my UI so that I can see when the executable is being executed.

<UI>
  <ProgressText Action="InstallVCRedistributable">Installing Visual C++ Redistributable for Visual Studio 2015</ProgressText>
</UI>

现在,当我运行我的安装程序时,它应该启动 vcredist_x64.exe...并且它确实...但是在安装该可执行文件的过程中它被挂断了.我收到一条弹出消息,指出此 Windows 安装程序包存在问题,并且作为安装程序的一部分运行的程序未完成.然后它回滚我的主应用程序安装并且永远不会被安装.谁能解释为什么会发生这种情况以及如何解决?谢谢!

Now, when I run my installer it should launch the vcredist_x64.exe... and it does... but then during the installation of that executable it gets hung up. I get a popup message that says there is a problem with this Windows Installer Package and that a program run as part of the setup did not complete. It then rolls-back my main application installation and never gets installed. Can anyone explain why this is happening and how to fix it? Thanks!

推荐答案

我发现这个问题并自己尝试了,处于同样的情况.我发现您遇到的安装程序错误是/是错误 1618:另一个安装正在进行中."似乎在您自己的安装程序中运行 vc_redist 安装程序根本行不通.

I found this question and tried it myself, being in the same situation. I found the installer error you're running into was/is Error 1618: "Another installation is already in progress." It seems that running the vc_redist installer inside your own installer simply won't work.

您的其他选项似乎是创建引导程序,如 Patrick Allwood 上面建议的那样,或者只是要求用户在运行自己的安装程序之前自行安装 vc_redist 包.您可以通过检查 C:WindowsSystem32 中的 ucrtbase.dll 来检测通用 C 运行时是否已经存在:

Your other options seem to be creating a bootstrapper as Patrick Allwood suggests above, or simply asking users to install the vc_redist package on their own before running your own installer. You can detect if the Universal C Runtime is already present by checking for ucrtbase.dll in C:WindowsSystem32:

<Property Id="UCRTINSTALLED">
  <DirectorySearch Id="UCRTSystemSearch" Path="[WindowsFolder]System32" Depth="0">
    <FileSearch Id="UCRTFileSearch" Name="ucrtbase.dll" MinVersion="10.0.10240.16389" />
  </DirectorySearch>
</Property>

如果您只有 32 位安装程序,您也可以直接使用 [SystemFolder] 属性.

If you only have a 32-bit installer, you can also use the [SystemFolder] property directly.

正如 Kevin Smyth 提到的,ucrtbase.dll 的版本出现了奇怪的问题 - 向某些工具报告 2.X 版,向其他工具报告 10.Y 版.如果您只想检查 ucrtbase.dll 的存在,您可以删除 MinVersion 属性.

As Kevin Smyth mentioned, the version of ucrtbase.dll is giving weird issues - reporting version 2.X to some tools, and version 10.Y to other tools. You can remove the MinVersion property if you just want to check for the existence of ucrtbase.dll.

这篇关于WIX 在安装时运行 vcredist_x64.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆