mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Fix Import-Module to honor 'ScriptsToProcess' when '-Version' is specified (#3897)
This commit is contained in:
1 parent
924f281c96
commit
28ec9a3511
2 files changed
+87
-26
No files matched your search
@@ -2768,38 +2768,58 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
if (scriptsToProcess != null)
|
||||
{
|
||||
foreach (string scriptFile in scriptsToProcess)
|
||||
{
|
||||
bool found = false;
|
||||
PSModuleInfo module = LoadModule(scriptFile,
|
||||
moduleBase,
|
||||
string.Empty, // prefix (-Prefix shouldn't be applied to dot sourced scripts)
|
||||
null,
|
||||
ref options,
|
||||
manifestProcessingFlags,
|
||||
out found);
|
||||
{
|
||||
Version savedBaseMinimumVersion = BaseMinimumVersion;
|
||||
Version savedBaseMaximumVersion = BaseMaximumVersion;
|
||||
Version savedBaseRequiredVersion = BaseRequiredVersion;
|
||||
Guid? savedBaseGuid = BaseGuid;
|
||||
|
||||
// If we're in analysis, add the detected exports to this module's
|
||||
// exports
|
||||
if (found && (ss == null))
|
||||
try
|
||||
{
|
||||
BaseMinimumVersion = null;
|
||||
BaseMaximumVersion = null;
|
||||
BaseRequiredVersion = null;
|
||||
BaseGuid = null;
|
||||
|
||||
foreach (string scriptFile in scriptsToProcess)
|
||||
{
|
||||
foreach (string detectedCmdlet in module.ExportedCmdlets.Keys)
|
||||
{
|
||||
manifestInfo.AddDetectedCmdletExport(detectedCmdlet);
|
||||
}
|
||||
bool found = false;
|
||||
PSModuleInfo module = LoadModule(scriptFile,
|
||||
moduleBase,
|
||||
string.Empty, // prefix (-Prefix shouldn't be applied to dot sourced scripts)
|
||||
null,
|
||||
ref options,
|
||||
manifestProcessingFlags,
|
||||
out found);
|
||||
|
||||
foreach (string detectedFunction in module.ExportedFunctions.Keys)
|
||||
// If we're in analysis, add the detected exports to this module's
|
||||
// exports
|
||||
if (found && (ss == null))
|
||||
{
|
||||
manifestInfo.AddDetectedFunctionExport(detectedFunction);
|
||||
}
|
||||
foreach (string detectedCmdlet in module.ExportedCmdlets.Keys)
|
||||
{
|
||||
manifestInfo.AddDetectedCmdletExport(detectedCmdlet);
|
||||
}
|
||||
|
||||
foreach (string detectedAlias in module.ExportedAliases.Keys)
|
||||
{
|
||||
manifestInfo.AddDetectedAliasExport(detectedAlias,
|
||||
module.ExportedAliases[detectedAlias].Definition);
|
||||
foreach (string detectedFunction in module.ExportedFunctions.Keys)
|
||||
{
|
||||
manifestInfo.AddDetectedFunctionExport(detectedFunction);
|
||||
}
|
||||
|
||||
foreach (string detectedAlias in module.ExportedAliases.Keys)
|
||||
{
|
||||
manifestInfo.AddDetectedAliasExport(detectedAlias,
|
||||
module.ExportedAliases[detectedAlias].Definition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
BaseMinimumVersion = savedBaseMinimumVersion;
|
||||
BaseMaximumVersion = savedBaseMaximumVersion;
|
||||
BaseRequiredVersion = savedBaseRequiredVersion;
|
||||
BaseGuid = savedBaseGuid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user