fix: handle older VC redist versions (#5447)
This commit is contained in:
@@ -42,7 +42,7 @@ $VCRTVersion = (Get-Item "$Env:VCToolsRedistDir\vc_redist.x64.exe").VersionInfo;
|
||||
ISCC `
|
||||
/DWORKING_DIR="$($pwd.Path)\" `
|
||||
/DINSTALLER_BASE_NAME="$installerBaseName" `
|
||||
/DSHIPPED_VCRT_BUILD="$($VCRTVersion.FileBuildPart)" `
|
||||
/DSHIPPED_VCRT_MINOR="$($VCRTVersion.FileMinorPart)" `
|
||||
/DSHIPPED_VCRT_VERSION="$($VCRTVersion.FileDescription)" `
|
||||
$defines `
|
||||
/O. `
|
||||
|
||||
@@ -120,15 +120,15 @@ begin
|
||||
Result := VCRTVersion + ' is installed';
|
||||
end;
|
||||
|
||||
// Checks if a new VCRT is needed by comparing the builds.
|
||||
// Checks if a new VCRT is needed by comparing the minor version (the major one is locked at 14).
|
||||
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
|
||||
if RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Minor', VCRTBuild) then
|
||||
begin
|
||||
if VCRTBuild >= {#SHIPPED_VCRT_BUILD} then
|
||||
if VCRTBuild >= {#SHIPPED_VCRT_MINOR} then
|
||||
Result := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
param (
|
||||
[string] $InstallDir = "Chatterino2"
|
||||
)
|
||||
|
||||
if ($null -eq $Env:VCToolsRedistDir) {
|
||||
Write-Error "VCToolsRedistDir is not set. Forgot to set Visual Studio environment variables?";
|
||||
exit 1
|
||||
}
|
||||
|
||||
# A path to the runtime libraries (e.g. "$Env:VCToolsRedistDir\onecore\x64\Microsoft.VC143.CRT")
|
||||
$vclibs = (Get-ChildItem "$Env:VCToolsRedistDir\onecore\x64" -Filter '*.CRT')[0].FullName;
|
||||
|
||||
# All executables and libraries in the installation directory
|
||||
$targets = Get-ChildItem -Recurse -Include '*.dll', '*.exe' $InstallDir;
|
||||
# All dependencies of the targets (with duplicates)
|
||||
$all_deps = $targets | ForEach-Object { (dumpbin /DEPENDENTS $_.FullName) -match '^(?!Dump of).+\.dll$' } | ForEach-Object { $_.Trim() };
|
||||
# All dependencies without duplicates
|
||||
$dependencies = $all_deps | Sort-Object -Unique;
|
||||
|
||||
$n_deployed = 0;
|
||||
foreach ($dll in $dependencies) {
|
||||
Write-Output "Checking for $dll";
|
||||
if (Test-Path -PathType Leaf "$vclibs\$dll") {
|
||||
Write-Output "Deploying $dll";
|
||||
Copy-Item "$vclibs\$dll" "$InstallDir\$dll" -Force;
|
||||
$n_deployed++;
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output "Deployed $n_deployed libraries";
|
||||
Reference in New Issue
Block a user