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
ModuleFast will now check at install time if the manifest GUID does not match what was in the spec. We unfortunately cannot do this earlier in the process without fully downloading the modules, as Nuget v3 doesn't have a standard location to store the GUID for PowerShell modules in the metadata. There could potentially be a tag like "GUID:XXX-YYY-ZZZ" used for this purpose in the future.
A warning was also added against using GUID to match in general.
Fixes#43
Copy file name to clipboardExpand all lines: ModuleFast.psm1
+66-34Lines changed: 66 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -445,7 +445,7 @@ function Get-ModuleFastPlan {
445
445
THIS COMMAND IS DEPRECATED AND WILL NOT RECEIVE PARAMETER UPDATES. Please use Install-ModuleFast -Plan instead.
446
446
#>
447
447
[CmdletBinding()]
448
-
[OutputType([ModuleFastInfo])]
448
+
[OutputType([ModuleFastInfo[]])]
449
449
param(
450
450
#The module(s) to install. This can be a string, a ModuleSpecification, a hashtable with nuget version style (e.g. @{Name='test';Version='1.0'}), a hashtable with ModuleSpecification style (e.g. @{Name='test';RequiredVersion='1.0'}),
451
451
[Alias('Name')]
@@ -543,6 +543,10 @@ function Get-ModuleFastPlan {
543
543
throw'Failed to find Module Specification for completed task. This is a bug.'
544
544
}
545
545
546
+
if ($currentModuleSpec.Guid-ne [Guid]::Empty) {
547
+
Write-Warning"${currentModuleSpec}: A GUID constraint was found in the module spec. ModuleSpec will currently only verify GUIDs after the module has been installed, so a plan may not be accurate. It is not recommended to match modules by GUID in ModuleFast."
#FIXME: This should be using Import-ModuleManifest but it needs to be brought in via the ThreadJob context. This will fail if the module has a dynamic manifest.
939
+
$manifest=Import-PowerShellDataFile$manifestPath
940
+
if ($manifest.Guid-ne$context.Module.Guid) {
941
+
Remove-Item$installPath-Force -Recurse
942
+
throw [InvalidOperationException]"$($context.Module): The installed package GUID does not match what was in the Module Spec. Expected $($context.Module.Guid) but found $($manifest.Guid) in $($manifestPath). Deleting this module, please check that your GUID specification is correct, or otherwise investigate why the GUID is different."
943
+
}
944
+
}
912
945
913
-
if (Test-Path$installIndicatorPath) {
914
946
#FIXME: Output inside a threadjob is not surfaced to the user.
915
-
Write-Warning"$($context.Module): Incomplete installation found at $installPath. Will delete and retry."
916
-
Remove-Item$installPath-Recurse -Force
947
+
Write-Debug"Cleanup Nuget Files in $installPath"
948
+
if (-not$installPath) { throw'ModuleDestination was not set. This is a bug, report it' }
@@ -1530,10 +1557,7 @@ function Find-LocalModule {
1530
1557
return
1531
1558
}
1532
1559
1533
-
#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.
1534
-
1535
-
#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.
1536
-
1560
+
#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. 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 ($ModuleSpec.Guid-and$ModuleSpec.Guid-ne [Guid]::Empty -and$manifestCandidate.Guid-ne$ModuleSpec.Guid) {
1667
+
Write-Warning"${ModuleSpec}: A locally installed module $folder that matches the module spec but the manifest GUID $($manifestCandidate.Guid) does not match the expected GUID $($ModuleSpec.Guid) in the spec. Verify your specification is correct otherwise investigate this module for why the GUID does not match."
0 commit comments