diff --git a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs index c6ac57070cb..4e572586c98 100644 --- a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs +++ b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs @@ -239,6 +239,8 @@ public enum XDG_Type DEFAULT } + private static string s_tempHomeDir = null; + /// /// Function for choosing directory location of PowerShell for profile loading. /// @@ -252,7 +254,8 @@ public static string SelectProductNameForDirectory(Platform.XDG_Type dirpath) string envHome = System.Environment.GetEnvironmentVariable(CommonEnvVariableNames.Home); if (envHome == null) { - envHome = GetTemporaryDirectory(); + s_tempHomeDir ??= GetTemporaryDirectory(); + envHome = s_tempHomeDir; } string xdgConfigHomeDefault = Path.Combine(envHome, ".config", "powershell");