From 8dc62afb5f98cafee20657251a12d52eeb6ce977 Mon Sep 17 00:00:00 2001 From: Mariah Date: Fri, 2 Mar 2018 17:01:59 -0800 Subject: [PATCH] Update CimDSCParser to fix Configuration compilation for DSC (#6225) Update CimDSCParser to fix Configuration compilation for DSC --- .../DscSupport/CimDSCParser.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/System.Management.Automation/DscSupport/CimDSCParser.cs b/src/System.Management.Automation/DscSupport/CimDSCParser.cs index b66740b483..ad68c07caa 100644 --- a/src/System.Management.Automation/DscSupport/CimDSCParser.cs +++ b/src/System.Management.Automation/DscSupport/CimDSCParser.cs @@ -667,7 +667,18 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal } else { - var systemResourceRoot = Path.Combine(Platform.GetFolderPath(Environment.SpecialFolder.System), "Configuration"); + // DSC SxS scenario + var configSystemPath = Utils.DefaultPowerShellAppBase; + var systemResourceRoot = Path.Combine(configSystemPath, "Configuration"); + var inboxModulePath = "Modules\\PSDesiredStateConfiguration"; + + if (!Directory.Exists(systemResourceRoot)) + { + configSystemPath = Platform.GetFolderPath(Environment.SpecialFolder.System); + systemResourceRoot = Path.Combine(configSystemPath, "Configuration"); + inboxModulePath = InboxDscResourceModulePath; + } + var programFilesDirectory = Platform.GetFolderPath(Environment.SpecialFolder.ProgramFiles); Debug.Assert(programFilesDirectory != null, "Program Files environment variable does not exist!"); var customResourceRoot = Path.Combine(programFilesDirectory, "WindowsPowerShell\\Configuration"); @@ -708,7 +719,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal List modulePaths = new List(); if (modulePathList == null || modulePathList.Count == 0) { - modulePaths.Add(Path.Combine(Platform.GetFolderPath(Environment.SpecialFolder.System), InboxDscResourceModulePath)); + modulePaths.Add(Path.Combine(configSystemPath, inboxModulePath)); isInboxResource = true; } else