From bd0ba6771c4e6582a6e72274456d8ff29dfd9054 Mon Sep 17 00:00:00 2001 From: Chunqing Chen Date: Thu, 14 Jul 2016 12:42:47 -0700 Subject: [PATCH 1/2] msft:8027609 Get-Module -List and Test-ModuleManifest import the the nested module dependencies into the current/global runspace. --- .../engine/Modules/ImportModuleCommand.cs | 6 +++++- .../engine/Modules/ModuleCmdletBase.cs | 9 ++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs b/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs index 2e5562d38d8..4e7f146ec69 100644 --- a/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs +++ b/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs @@ -652,7 +652,11 @@ private PSModuleInfo ImportModule_LocallyViaName(ImportModuleOptions importModul else if (Directory.Exists(rootedPath)) { // Load the latest valid version if it is a multi-version module directory - foundModule = LoadUsingMultiVersionModuleBase(rootedPath, importModuleOptions, out found); + foundModule = LoadUsingMultiVersionModuleBase(rootedPath, + ManifestProcessingFlags.LoadElements | + ManifestProcessingFlags.WriteErrors | + ManifestProcessingFlags.NullOnFirstError, + importModuleOptions, out found); if (!found) { diff --git a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs index fb6c1c372b0..6e15ac3df8e 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs @@ -388,7 +388,7 @@ internal bool LoadUsingModulePath(PSModuleInfo parentModule, bool found, IEnumer string qualifiedPath = Path.Combine(path, fileBaseName); // Load the latest valid version if it is a multi-version module directory - module = LoadUsingMultiVersionModuleBase(qualifiedPath, options, out found); + module = LoadUsingMultiVersionModuleBase(qualifiedPath, manifestProcessingFlags, options, out found); if (!found) { @@ -432,10 +432,11 @@ internal bool LoadUsingModulePath(PSModuleInfo parentModule, bool found, IEnumer /// Loads the latest valid version if moduleBase is a multi-versioned module directory /// /// module directory path + /// The flag that indicate manifest processing option /// The set of options that are used while importing a module /// True if a module was found /// - internal PSModuleInfo LoadUsingMultiVersionModuleBase(string moduleBase, ImportModuleOptions importModuleOptions, out bool found) + internal PSModuleInfo LoadUsingMultiVersionModuleBase(string moduleBase, ManifestProcessingFlags manifestProcessingFlags, ImportModuleOptions importModuleOptions, out bool found) { PSModuleInfo foundModule = null; found = false; @@ -465,9 +466,7 @@ internal PSModuleInfo LoadUsingMultiVersionModuleBase(string moduleBase, ImportM null, this.BasePrefix, /*SessionState*/ null, importModuleOptions, - ManifestProcessingFlags.LoadElements | - ManifestProcessingFlags.WriteErrors | - ManifestProcessingFlags.NullOnFirstError, + manifestProcessingFlags, out found); if (found) { From 080f029d8ac29ee9be6cad51b549c8edff5eb157 Mon Sep 17 00:00:00 2001 From: Chunqing Chen Date: Thu, 14 Jul 2016 13:21:28 -0700 Subject: [PATCH 2/2] msft:7980238, 7768797 Test-ModuleManifest loads all available modules if a module has the nested module dependencies. Get-Module -List and Test-ModuleManifest import the the nested module dependencies into the current runspace. --- .../engine/Modules/TestModuleManifestCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/Modules/TestModuleManifestCommand.cs b/src/System.Management.Automation/engine/Modules/TestModuleManifestCommand.cs index b74c18bfad0..f5e81a26f0e 100644 --- a/src/System.Management.Automation/engine/Modules/TestModuleManifestCommand.cs +++ b/src/System.Management.Automation/engine/Modules/TestModuleManifestCommand.cs @@ -175,7 +175,7 @@ protected override void ProcessRecord() { foreach (ModuleSpecification requiredModule in requiredModules) { - var modules = GetModule(new[] { requiredModule.Name }, true, true); + var modules = GetModule(new[] { requiredModule.Name }, false, true); if (modules.Count == 0) { string errorMsg = StringUtil.Format(Modules.InvalidRequiredModulesinModuleManifest, requiredModule.Name, filePath);