WIX run vcredist_x64.exe on install
Asked Answered
V

3

14

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.

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>

And...

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

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>

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>

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!

Vicechancellor answered 15/1, 2016 at 16:28 Comment(2)
FYI, adding Microsoft_VC140_CRT_x64.msm in your installer will work so long as the target system also has the Universal CRT installed. The merge module itself is no longer completely self-dependent.Irrecusable
Have you solved this problem? I'm in a same situation as you are. I have my own EULA and I need to add c++ redist. 2017 to my setup file but all the answers are old and using .msm files, I'm really new to this WiX setup progress so the .msm files might work but I don't know how to use them..Cran
N
6

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.

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:\Windows\System32:

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

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

EDIT: 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.

Northumbrian answered 10/2, 2016 at 14:32 Comment(3)
I can't get it to work with MinVersion?! (I have "10.0.10586.0" on my ucrtbase.dll) Any ideas?Synchromesh
This MinVersion check fails! win32api.GetFileVersionInfo('ucrtbase.dll', '\\') returns 2.6.10586.0 for the file version on my Windows 10 machine. sigcheck.exe returns 10.0.10586.0. Very odd. Worse, msiexec /i /log*xv doesn't log anything useful. I removed MinVersion and it works.Roughhouse
FYI: finding ucrtbase.dll will confirm that the "Universal CRT" is installed. The UCRT is a requirement for the MSVC 2015 redistributables, and vc_redist.exe will cause them to be installed if they are missed. However the UCRT is delivered through Windows Update, and so it is quite possible for ucrtbase.dll to be installed without the MSVC 2015 redistributables being installed. tl;dr: Don't use the existence of ucrtbase.dll to decide whether to launch vc_redist.exe or not.Irrecusable
R
5

I think the correct approach to take when having prerequisites that have their own installers is to create a WiX bootstrapper bundle, which runs through each installer in turn. This handles things like rollbacks on install failures, etc, which running custom actions from within an installer does not.

A barebones sample can be seen here, you add <MsiPackage> and <ExePackage> in the Chain element in the order you need them to install.

Rainout answered 15/1, 2016 at 17:15 Comment(4)
I was kinda hoping I could get away without using a bootstrapper. But, it might not be possible. The main reason is that I've already got a custom .msi file which displays my EULA in different cultures automatically. I'm not sure if it's possible to omit the license file with the bootstrap application and just use it to install the .msi and then the vcredist_x64.exe in one go. But, I guess I need to do some more digging. If you have any other, possibly more 'elegant' or 'msi-friendly' ways to do this, please let me know.Vicechancellor
Also, does anyone know why my current implementation, which uses a custom action to launch the .exe file is failing? It seems like it should work. Is it because the vcredist_x64.exe has a check box on installing which asks you to agree to their terms and conditions. Could this be causing my installer to fail?Vicechancellor
You can have the bootstrapper show your MSI installer interface when you run it, and I think you can set the bootstrapper to have no ui as well.Rainout
With respect to your second comment - run your msi from the command line with logging, examine the log file. It's messy to read, but you get a full trace of what's going on.Rainout
A
-1

I was facing a similar problem (fully described in this closed question, which actually redirected me here). I was able to solve it, inspired by this entry about running the application after setup.

The key part is basically to add a final step to the UI that launches the vcredist installer:

<UI Id="UI_Main">
  <!-- ...... -->
  <Publish Dialog="ExitDialog"
           Control="Finish"
           Event="DoAction"
           Value="InstallVCRedistributable">1</Publish>
</UI>

Regarding the custom action:

<CustomAction Id="InstallVCRedistributable"
              FileKey="VCREDISEXE"
              ExeCommand="/install /passive /norestart"
              Impersonate="yes"
              Return="asyncNoWait" />
Asbestos answered 18/9, 2020 at 13:29 Comment(1)
I found this Q&A super helpful. However, would it be possible to auto-delete the VCRedist.exe after the installation is completed? When I delete the VCRedist.exe programmatically with my main executable, it causes my main executable to "think" that the install needs repaired before starting the next time.Exserviceman

© 2022 - 2024 — McMap. All rights reserved.