From d40131ae44a685e233e3db9388c54b329e712c23 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Thu, 21 Jul 2016 13:58:59 -0700 Subject: [PATCH] Clean up PSMODULEPATH Windows work-around --- .../engine/Modules/ModuleIntrinsics.cs | 13 +++++++------ src/System.Management.Automation/engine/Utils.cs | 16 ++++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs b/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs index f6b08d4beb..8d60465512 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs @@ -778,12 +778,13 @@ namespace System.Management.Automation { // Now handle the case where the environment variable is already set. - // Porting note: Open PowerShell has a Modules folder in the the application base path which contains the built-in modules - // It must be in the front of the path no matter what. - if (Platform.IsCore) - { - currentProcessModulePath = AddToPath(currentProcessModulePath, GetSystemwideModulePath(), 0); - } + // CoreCLR PowerShell on Windows has a Modules folder in the the application base + // path which contains the built-in modules It must be in the front of the path no + // matter what, regardless of inherited path. +#if CORECLR && !UNIX + // TODO: #1184 will resolve this work-around + currentProcessModulePath = AddToPath(currentProcessModulePath, GetSystemwideModulePath(), 0); +#endif // If there is no personal path key, then if the env variable doesn't match the system variable, // the user modified it somewhere, else prepend the default personel module path diff --git a/src/System.Management.Automation/engine/Utils.cs b/src/System.Management.Automation/engine/Utils.cs index fd53861df1..3309572433 100644 --- a/src/System.Management.Automation/engine/Utils.cs +++ b/src/System.Management.Automation/engine/Utils.cs @@ -296,14 +296,14 @@ namespace System.Management.Automation // And built-in modules string progFileDir; - if (Platform.IsCore) - { - progFileDir = Path.Combine(appBase, "Modules"); - } - else - { - progFileDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "WindowsPowerShell", "Modules"); - } + // TODO: #1184 will resolve this work-around + // Side-by-side versions of PowerShell use modules from their application base, not + // the system installation path. +#if CORECLR + progFileDir = Path.Combine(appBase, "Modules"); +#else + progFileDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "WindowsPowerShell", "Modules"); +#endif if (!string.IsNullOrEmpty(progFileDir)) {