Skip to content

Commit

Permalink
Install MSVC Redistributable with MSI Installer
Browse files Browse the repository at this point in the history
* Fixes #7564
  • Loading branch information
droidmonkey committed Oct 1, 2022
1 parent eaa363d commit 97e1f8c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
22 changes: 22 additions & 0 deletions share/windows/wix-template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,30 @@
<Property Id="WixSilentExecCmdLine" Value='taskkill /IM KeePassXC.exe; taskkill /IM keepassxc-proxy.exe /F' />
<CustomAction Id="KillKeePassXC" BinaryKey="WixCA" DllEntry="WixSilentExec" Execute="immediate" Return="ignore" />

<?ifdef MSVCBUILD?>
<!-- MSVC Redistributable Installer -->
<Property Id="VCREDISTINSTALLED">
<RegistrySearch Id="VCRedistInstalledSearch"
Root="HKLM"
Key="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\[PLATFORM]"
Name="Installed"
Type="raw" />
</Property>
<Property Id="VCREDISTMINORVERSION">
<RegistrySearch Id="VCRedistMinorVersionSearch"
Root="HKLM"
Key="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\[PLATFORM]"
Name="Minor"
Type="raw" />
</Property>
<CustomAction Id="InstallVCRedist" FileKey="CM_FP_redist.vc_redist.exe" ExeCommand="/quiet /norestart" Execute="deferred" Impersonate="no" Return="ignore" />
<?endif?>

<InstallExecuteSequence>
<Custom Action="KillKeePassXC" Before="InstallValidate" />
<?ifdef MSVCBUILD?>
<Custom Action="InstallVCRedist" Before="InstallFinalize"><![CDATA[NOT REMOVE AND (NOT VCREDISTINSTALLED OR VCREDISTMINORVERSION < "#32")]]></Custom>
<?endif?>
<!-- Prevent pinned taskbar shortcut from being removed -->
<RemoveShortcuts Suppress="yes" />
</InstallExecuteSequence>
Expand Down
14 changes: 14 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,10 @@ install(TARGETS ${PROGNAME}
if(WIN32)
if(${CMAKE_SIZEOF_VOID_P} EQUAL "8")
set(OUTPUT_FILE_POSTFIX "Win64")
set(CPACK_WIX_PROPERTY_PLATFORM "x64")
else()
set(OUTPUT_FILE_POSTFIX "Win32")
set(CPACK_WIX_PROPERTY_PLATFORM "x86")
endif()

# We have to copy the license file in the configuration phase.
Expand Down Expand Up @@ -477,6 +479,9 @@ if(WIN32)
"${CMAKE_SOURCE_DIR}/share/windows/KPXC_ExitDlg.wxs")
set(CPACK_WIX_PROPERTY_ARPURLINFOABOUT "https://keepassxc.org")
set(CPACK_WIX_EXTENSIONS "WixUtilExtension.dll")
if(MSVC)
set(CPACK_WIX_CANDLE_EXTRA_FLAGS "-dMSVCBUILD")
endif()
include(CPack)

if(NOT VCPKG_INSTALLED_DIR)
Expand Down Expand Up @@ -520,6 +525,15 @@ if(WIN32)
endif()
endif()

if(MSVC)
# Install VC++ Redistributable Installer
find_file(VCREDIST vc_redist.$ENV{VSCMD_ARG_TGT_ARCH}.exe PATHS "$ENV{VCINSTALLDIR}Redist/MSVC/v143" "$ENV{VCINSTALLDIR}Redist/MSVC/v142")
if(NOT VCREDIST)
message(FATAL_ERROR "Failed to find MSVC Redistributable installer, ensure it is installed with MSVC")
endif()
install(PROGRAMS "${VCREDIST}" DESTINATION "redist" RENAME "vc_redist.exe")
endif()

# install CA cert chains
find_file(SSL_CA_BUNDLE ca-bundle.crt PATHS "${Qt5_PREFIX}/ssl/certs")
if(SSL_CA_BUNDLE)
Expand Down

0 comments on commit 97e1f8c

Please sign in to comment.