Search code examples
visual-c++wixwindows-installervisual-studio-2022merge-module

VisualStudio 2022 CRT MergeModules overwrites newer msvcp140.dll


My C++ application is built with Visual Studio 2022 v17.4, which has MSVC tools 14.34.31933, and then Windows installation package .MSI is created with WiX Toolset.

Product.wxs file contains the lines as follows to include VC Redistributable:

    <DirectoryRef Id="TARGETDIR">
      <Merge Id="VCRedist" SourceFile="$(env.ProgramW6432)\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\v143\MergeModules\Microsoft_VC143_CRT_x64.msm" DiskId="1" Language="0"/>
    </DirectoryRef>
    <Feature Id="VCRedist" Title="Microsoft VC143 CRT" AllowAdvertise="no" Display="hidden" Level="1">
      <MergeRef Id="VCRedist"/>
    </Feature>

With the release of Visual Studio 2022 v17.10, it turned out that my installer overwrites newer C:\Windows\System32\msvcp140.dll version 14.40.33810.0 with older version 14.34.31931.0. After that all programs built in the latest Visual Studio crash on start due to std::mutex::lock() incompatibility.

In the log of installation produced by the command:

msiexec /i myapp.msi /L*V install.log

I see

MSI (s) (D0:7C) [12:07:18:334]: Feature: VCRedist; Installed: Absent;   Request: Local;   Action: Local
...
MSI (s) (D0:7C) [12:07:18:344]: Component: msvcp140.dll_system_amd64.DFEFC2FE_EEE6_424C_841B_D4E66F0C84A3; Installed: Absent;   Request: Local;   Action: Local

as if no newer redistributable are found at all.

What must be changed in WiX project, for .MSI file installed MSVC Redistributable only if its newer than already in the system, and did not change it otherwise?


Solution

  • Those log lines just say the Component isn't registered on the machine. They aren't the problem. Later in the log file you'll see messages about the actual files being installed and those are more useful.

    My bet is you have REINSTALLMODE set forcing overwrites. But you don't provide enough information about what your code to know.