From d901ed177bc3309ce8e8c391d6d04b072a7189a9 Mon Sep 17 00:00:00 2001 From: JohnMcPMS Date: Fri, 13 Oct 2023 09:05:47 -0700 Subject: [PATCH] Allow higher versions to satisfy the dependency (#3763) Rather than looking for the explicit version of the VCLibs dependency, this change allows any version greater than or equal to satisfy the installed check. This does not resolve the fact that we are using a hardcoded version, nor that we are not checking for the same set of architectures that we would install. Also fixes the helper script to import the dev modules directly so that it can be used even when the release modules are present in the module path. --- .../Helpers/AppxModuleHelper.cs | 18 ++++++++++++++++-- .../scripts/Initialize-LocalWinGetModules.ps1 | 12 ++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/AppxModuleHelper.cs b/src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/AppxModuleHelper.cs index ecd1c68179..403c1e9d14 100644 --- a/src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/AppxModuleHelper.cs +++ b/src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/AppxModuleHelper.cs @@ -6,6 +6,7 @@ namespace Microsoft.WinGet.Client.Engine.Helpers { + using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -254,15 +255,28 @@ private void InstallVCLibsDependencies() { Name, VCLibsUWPDesktop }, }); - // See if the required version is installed. + // See if the minimum (or greater) version is installed. + // TODO: Pull the minimum version from the target package + // TODO: This does not check architecture of the package + Version minimumVersion = new Version(VCLibsUWPDesktopVersion); + bool isInstalled = false; if (result != null && result.Count > 0) { foreach (dynamic psobject in result) { - if (psobject?.Version == VCLibsUWPDesktopVersion) + string versionString = psobject?.Version?.ToString(); + if (versionString == null) + { + continue; + } + + Version packageVersion = new Version(versionString); + + if (packageVersion >= minimumVersion) { + this.psCmdlet.WriteDebug($"VCLibs dependency satisfied by: {psobject?.PackageFullName ?? ""}"); isInstalled = true; break; } diff --git a/src/PowerShell/scripts/Initialize-LocalWinGetModules.ps1 b/src/PowerShell/scripts/Initialize-LocalWinGetModules.ps1 index 77b00047c4..63314fd04b 100644 --- a/src/PowerShell/scripts/Initialize-LocalWinGetModules.ps1 +++ b/src/PowerShell/scripts/Initialize-LocalWinGetModules.ps1 @@ -59,16 +59,16 @@ if ($BuildRoot -eq "") $BuildRoot = "$PSScriptRoot\..\.."; } -# Add here new modules +# Modules, they should be in dependency order so that when importing we don't pick up the release modules. [WinGetModule[]]$local:modules = - [WinGetModule]::new( - "Microsoft.WinGet.DSC", - "$PSScriptRoot\..\Microsoft.WinGet.DSC\", - $false), [WinGetModule]::new( "Microsoft.WinGet.Client", "$PSScriptRoot\..\Microsoft.WinGet.Client\ModuleFiles\", $true), + [WinGetModule]::new( + "Microsoft.WinGet.DSC", + "$PSScriptRoot\..\Microsoft.WinGet.DSC\", + $false), [WinGetModule]::new( "Microsoft.WinGet.Configuration", "$PSScriptRoot\..\Microsoft.WinGet.Configuration\ModuleFiles\", @@ -111,6 +111,6 @@ if (-not $SkipImportModule) foreach($module in $modules) { Write-Host "Importing module $($module.Name)" -ForegroundColor Green - Import-Module $module.Name -Force + Import-Module "$moduleRootOutput\$($module.Name)\" -Force } }