From bdd7d95092b06c079c7a6dfc5e74195be2a54163 Mon Sep 17 00:00:00 2001 From: nerix Date: Sat, 30 Sep 2023 12:22:39 +0200 Subject: [PATCH] Check VCRT and show installed/shipped version (#4847) * feat: check VCRT and give more feedback * chore: add changelog entry * fix: use full product name --- .CI/build-installer.ps1 | 4 +++ .CI/chatterino-installer.iss | 49 +++++++++++++++++++++++++++++++++++- CHANGELOG.md | 1 + 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/.CI/build-installer.ps1 b/.CI/build-installer.ps1 index ed64e6a4..756a1503 100644 --- a/.CI/build-installer.ps1 +++ b/.CI/build-installer.ps1 @@ -36,10 +36,14 @@ if ($null -eq $Env:VCToolsRedistDir) { } Copy-Item "$Env:VCToolsRedistDir\vc_redist.x64.exe" .; +$VCRTVersion = (Get-Item "$Env:VCToolsRedistDir\vc_redist.x64.exe").VersionInfo; + # Build the installer ISCC ` /DWORKING_DIR="$($pwd.Path)\" ` /DINSTALLER_BASE_NAME="$installerBaseName" ` + /DSHIPPED_VCRT_BUILD="$($VCRTVersion.FileBuildPart)" ` + /DSHIPPED_VCRT_VERSION="$($VCRTVersion.FileDescription)" ` $defines ` /O. ` "$PSScriptRoot\chatterino-installer.iss"; diff --git a/.CI/chatterino-installer.iss b/.CI/chatterino-installer.iss index 34056571..e8e3a872 100644 --- a/.CI/chatterino-installer.iss +++ b/.CI/chatterino-installer.iss @@ -13,6 +13,15 @@ #define WORKING_DIR "" #endif +; Set to the build part of the VCRT version +#ifndef SHIPPED_VCRT_BUILD +#define SHIPPED_VCRT_BUILD 0 +#endif +; Set to the string representation of the VCRT version +#ifndef SHIPPED_VCRT_VERSION +#define SHIPPED_VCRT_VERSION ? +#endif + [Setup] ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) @@ -56,7 +65,8 @@ SetupWindowTitle=Setup - %1 (Nightly) #endif [Tasks] -Name: "vcredist"; Description: "Install the required Visual C++ 2015/2017/2019/2022 Redistributable"; +; Only show this option if the VCRT can be updated. +Name: "vcredist"; Description: "Install the required {#SHIPPED_VCRT_VERSION} ({code:VCRTDescription})"; Check: NeedsNewVCRT(); ; GroupDescription: "{cm:AdditionalIcons}"; Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; Flags: unchecked Name: "freshinstall"; Description: "Fresh install (delete old settings/logs)"; Flags: unchecked @@ -85,3 +95,40 @@ Type: filesandordirs; Name: "{userappdata}\Chatterino2"; Tasks: freshinstall [UninstallDelete] ; Delete cache on uninstall Type: filesandordirs; Name: "{userappdata}\Chatterino2\Cache" + +[Code] +// Get the VCRT version as a string. Null if the version could not be found. +function GetVCRT(): Variant; +var + VCRTVersion: String; +begin + Result := Null; + if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Version', VCRTVersion) then + Result := VCRTVersion; +end; + +// Gets a description about the VCRT installed vs shipped. +// This doesn't compare the versions. +function VCRTDescription(Param: String): String; +var + VCRTVersion: Variant; +begin + VCRTVersion := GetVCRT; + if VarIsNull(VCRTVersion) then + Result := 'none is installed' + else + Result := VCRTVersion + ' is installed'; +end; + +// Checks if a new VCRT is needed by comparing the builds. +function NeedsNewVCRT(): Boolean; +var + VCRTBuild: Cardinal; +begin + Result := True; + if RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Bld', VCRTBuild) then + begin + if VCRTBuild >= {#SHIPPED_VCRT_BUILD} then + Result := False; + end; +end; diff --git a/CHANGELOG.md b/CHANGELOG.md index 34d073cb..33be03f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Minor: Migrate to the new Get Channel Followers Helix endpoint, fixing follower count not showing up in usercards. (#4809) - Minor: The account switcher is now styled to match your theme. (#4817) - Minor: Add an invisible resize handle to the bottom of frameless user info popups and reply thread popups. (#4795) +- Minor: The installer now checks for the VC Runtime version and shows more info when it's outdated. (#4847) - Bugfix: Trimmed custom streamlink paths on all platforms making sure you don't accidentally add spaces at the beginning or end of its path. (#4834) - Bugfix: Fixed a performance issue when displaying replies to certain messages. (#4807) - Bugfix: Fixed a data race when disconnecting from Twitch PubSub. (#4771)