You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$planAlreadySatisfiedMessage="`u{2705}$($ModulesToInstall.count) Module Specifications have all been satisfied by installed modules. If you would like to check for newer versions remotely, specify -Update"
Write-Warning'No PSModulePaths found in $env:PSModulePath. If you are doing isolated testing you can disregard this.'
1253
1259
return
1254
1260
}
1255
1261
1256
-
#First property is the manifest path, second property is the actual version (may be different from the folder version as prerelease versions go in the same location)
1262
+
#We want to minimize reading the manifest files, so we will do a fast file-based search first and then do a more detailed inspection on high confidence candidate(s). Any module in any folder path that satisfies the spec will be sufficient, we don't care about finding the "latest" version, so we will return the first module that satisfies the spec.
1257
1263
1264
+
#We will store potential candidates in this list, with their evaluated "guessed" version based on the folder name and the path. The first items added to the list should be the highest likelihood candidates in Path priority order, so no sorting should be necessary.
if ($versionedManifestPath.count-gt1) { throw"$folder manifest is ambiguous, this happens on Linux if you have two manifests with different case sensitivity. Please delete one of these: $versionedManifestPath" }
1308
+
#Fast filter items that are above the upper bound, we dont need to read these manifests
1309
+
if ($ModuleSpec.Max-and$version-gt$ModuleSpec.Max.Version) {
1310
+
Write-Debug"${ModuleSpec}: Skipping $folder - above the upper bound"
1311
+
return
1312
+
}
1316
1313
1317
-
if (-not$versionedManifestPath) {
1318
-
Write-Warning"Found a candidate versioned module folder $folder but no $manifestName manifest was found in the folder. This is an indication of a corrupt module and you should clean this folder up"
1319
-
continue
1320
-
}
1314
+
#We can fast filter items that are below the lower bound, we dont need to read these manifests
1315
+
if ($ModuleSpec.Min) {
1316
+
#HACK: Nuget does not correctly convert major.minor.build versions.
#TODO: Optimize this so that import-powershelldatafile is not called twice. This should be a rare occurance so it's not a big deal.
1335
+
#NOTE: This does result in Import-PowerShellData getting called twice which isn't ideal for performance, but classic modules should be fairly rare and not worth optimizing.
#If we get this far, we didn't find a manifest in this module path
1341
-
Write-Debug"$moduleSpec`: module folder exists at $moduleBaseDir but no modules found that match the version spec."
1342
-
}
1343
-
1344
-
if ($candidateModules.count-eq0) { return$null }
1345
-
1346
-
# We have to read the manifests to verify if the specified installed module is a prerelease module, which can affect whether it is selected by this function.
1347
-
# TODO: Filter to likely candidates first
1348
-
#NOTE: We use the sort rather than FindBestMatch because we want the highest compatible version, due to auto assembly redirect in PSCore
#The ModuleSpec.Max.Version check is to support an edge case where the module prerelease version is actually less than the prerelease constraint but we haven't read the manifest yet to determine that.
1354
-
if (-not$ModuleSpec.SatisfiedBy($version) -and$ModuleSpec.Max.Version-ne$version) {
1355
-
Write-Debug"$($ModuleSpec.Name): Found a module $($moduleInfo.Item2) that matches the name but does not satisfy the version spec $($ModuleSpec). Skipping..."
1342
+
if ($candidatePaths.count-eq0) {
1343
+
Write-Debug"${ModuleSpec}: Skipping PSModulePath $modulePath - No installed versions matched the spec."
if (-not [Version]::TryParse($manifestData.ModuleVersion, [ref]$manifestVersionData)) {
1363
-
Write-Warning"Found a manifest at $manifestPath but the version $($manifestData.ModuleVersion) in the manifest information is not a valid version. This is probably an invalid or corrupt manifest"
#Re-Test against the manifest loaded version to be sure
1373
-
if (-not$ModuleSpec.SatisfiedBy($manifestVersion)) {
1374
-
Write-Debug"$($ModuleSpec.Name): Found a module $($moduleInfo.Item2) that initially matched the name and version folder but after reading the manifest, the version label not satisfy the version spec $($ModuleSpec). This is an edge case and should only occur if you specified a prerelease upper bound that is less than the PreRelease label in the manifest. Skipping..."
1375
-
continue
1376
-
}
1355
+
if ($versionedManifestPath.count-gt1) { throw"$folder manifest is ambiguous, this happens on Linux if you have two manifests with different case sensitivity. Please delete one of these: $versionedManifestPath" }
1377
1356
1378
-
#If Update is specified, we will be more strict and only report a matching module if it exactly matches the upper bound of the version spec (otherwise there may be a newer module available remotely)
1379
-
if ($Update) {
1380
-
if ($ModuleSpec.Max-ne$manifestVersion) {
1381
-
Write-Debug"$($ModuleSpec.Name): Found a module $($moduleInfo.Item2) that matches the name and version folder but does not exactly match the upper bound of the version spec $($ModuleSpec). Skipping..."
1357
+
if (-not$versionedManifestPath) {
1358
+
Write-Warning"${ModuleSpec}: Found a candidate versioned module folder $folder but no $manifestName manifest was found in the folder. This is an indication of a corrupt module and you should clean this folder up"
1382
1359
continue
1383
-
} else {
1384
-
Write-Debug"$($ModuleSpec.Name): Found a module $($moduleInfo.Item2) that matches the name and version folder and exactly matches the upper bound of the version spec $($ModuleSpec) because -Update was specified, so it will not be evaluated for install"
1385
1360
}
1386
-
}
1387
1361
1388
-
#If we pass all sanity checks, we can return this module as meeting the criteria and skip checking all lower modules.
if ($Update-and ($ModuleSpec.Max-ne$candidateVersion)) {
1368
+
Write-Debug"${ModuleSpec}: Skipping $candidateVersion - The -Update was specified and the version does not exactly meet the upper bound of the spec, meaning there is a possible newer version remotely."
1369
+
continue
1370
+
}
1371
+
1372
+
#TODO: Collect InstalledButSatisfied Modules into an array so they can later be referenced in the lockfile and/or plan, right now the lockfile only includes modules that changed.
if (-not [Version]::TryParse($manifestData.ModuleVersion, [ref]$manifestVersionData)) {
1553
+
throw [InvalidDataException]"The manifest at $ManifestPath has an invalid ModuleVersion $($manifestData.ModuleVersion). This is probably an invalid or corrupt manifest"
0 commit comments