diff --git a/src/Microsoft.PowerShell.ScheduledJob/ScheduledJobStore.cs b/src/Microsoft.PowerShell.ScheduledJob/ScheduledJobStore.cs index 0cfb064db..22318157e 100644 --- a/src/Microsoft.PowerShell.ScheduledJob/ScheduledJobStore.cs +++ b/src/Microsoft.PowerShell.ScheduledJob/ScheduledJobStore.cs @@ -424,8 +424,11 @@ namespace Microsoft.PowerShell.ScheduledJob /// Directory Path public static string GetJobDefinitionLocation() { - return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), - ScheduledJobsPath); +#if UNIX + return Path.Combine(Platform.SelectProductNameForDirectory(Platform.XDG_Type.CACHE), "ScheduledJobs")); +#else + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ScheduledJobsPath); +#endif } public static void CreateDirectoryIfNotExists() @@ -444,9 +447,12 @@ namespace Microsoft.PowerShell.ScheduledJob /// Directory Path private static string GetDirectoryPath() { - string pathName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), - ScheduledJobsPath); - + string pathName; +#if UNIX + pathName = Path.Combine(Platform.SelectProductNameForDirectory(Platform.XDG_Type.CACHE), "ScheduledJobs")); +#else + pathName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ScheduledJobsPath); +#endif if (!Directory.Exists(pathName)) { Directory.CreateDirectory(pathName); @@ -499,9 +505,13 @@ namespace Microsoft.PowerShell.ScheduledJob /// Directory Path private static string GetJobDefinitionPath(string definitionName) { +#if UNIX + return Path.Combine(Platform.SelectProductNameForDirectory(Platform.XDG_Type.CACHE), "ScheduledJobs", definitionName); +#else return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ScheduledJobsPath, definitionName); +#endif } /// diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index 16f6a0571..32f1d4f75 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -3106,10 +3106,14 @@ namespace System.Management.Automation.Runspaces // Or for virtual accounts // WinDir\System32\Microsoft\Windows\PowerShell\DriveRoots\[UserName] string directoryName = MakeUserNamePath(); +#if UNIX + string userDrivePath = Path.Combine(Platform.SelectProductNameForDirectory(Platform.XDG_Type.CACHE), "DriveRoots", directoryName); +#else string userDrivePath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\Windows\PowerShell\DriveRoots", directoryName); +#endif // Create directory if it doesn't exist. if (!System.IO.Directory.Exists(userDrivePath))