From 05230384034b9843e25fcaec3779012408153357 Mon Sep 17 00:00:00 2001 From: Mariah Breakey Date: Fri, 23 Feb 2018 10:16:14 -0800 Subject: [PATCH 1/3] Updating DSC file to fix Config compilation --- .../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 b66740b4835..212428c8ca4 100644 --- a/src/System.Management.Automation/DscSupport/CimDSCParser.cs +++ b/src/System.Management.Automation/DscSupport/CimDSCParser.cs @@ -667,7 +667,18 @@ public static void Initialize(Collection errors, List moduleP } else { - var systemResourceRoot = Path.Combine(Platform.GetFolderPath(Environment.SpecialFolder.System), "Configuration"); + // DSC SxS scenario + var psAssembly = Assembly.GetEntryAssembly(); + var configSystemPath = Path.GetDirectoryName(psAssembly.Location); + 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 @@ public static void Initialize(Collection errors, List moduleP 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 From 42f526ccbe8d3e23605860d295caf7f5624e063e Mon Sep 17 00:00:00 2001 From: Mariah Breakey Date: Fri, 2 Mar 2018 10:40:06 -0800 Subject: [PATCH 2/3] adding get-module --- .../DscSupport/CimDSCParser.cs | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/System.Management.Automation/DscSupport/CimDSCParser.cs b/src/System.Management.Automation/DscSupport/CimDSCParser.cs index 212428c8ca4..5a38a452347 100644 --- a/src/System.Management.Automation/DscSupport/CimDSCParser.cs +++ b/src/System.Management.Automation/DscSupport/CimDSCParser.cs @@ -668,11 +668,26 @@ public static void Initialize(Collection errors, List moduleP else { // DSC SxS scenario - var psAssembly = Assembly.GetEntryAssembly(); - var configSystemPath = Path.GetDirectoryName(psAssembly.Location); + //var psAssembly = Assembly.GetEntryAssembly(); + var configSystemPath = Utils.DefaultPowerShellAppBase; var systemResourceRoot = Path.Combine(configSystemPath, "Configuration"); - var inboxModulePath = "Modules\\PSDesiredStateConfiguration"; - if( !Directory.Exists(systemResourceRoot)) + //var inboxModulePath = "Modules\\PSDesiredStateConfiguration"; + ExecutionContext context = null; + CommandInfo commandInfo = new CmdletInfo("Get-Module", typeof(Microsoft.PowerShell.Commands.GetModuleCommand), null, null, context); + System.Management.Automation.Runspaces.Command getModuleCommand = new System.Management.Automation.Runspaces.Command(commandInfo); + var psDesiredStateConfigurationModule = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace) + .AddCommand(getModuleCommand) + .AddParameter("List", true) + .AddParameter("Name", "PSDesiredStateConfiguration") + .AddParameter("ErrorAction", ActionPreference.Ignore) + .AddParameter("WarningAction", ActionPreference.Ignore) + .AddParameter("InformationAction", ActionPreference.Ignore) + .AddParameter("Verbose", false) + .AddParameter("Debug", false) + .Invoke(); + var inboxModulePath = psDesiredStateConfigurationModule[0].Path; + + if(!Directory.Exists(systemResourceRoot)) { configSystemPath = Platform.GetFolderPath(Environment.SpecialFolder.System); systemResourceRoot = Path.Combine(configSystemPath, "Configuration"); From b9c46083c52259f269cf57d6db83a69515d93878 Mon Sep 17 00:00:00 2001 From: Mariah Breakey Date: Fri, 2 Mar 2018 14:05:13 -0800 Subject: [PATCH 3/3] using hardcoded module path --- .../DscSupport/CimDSCParser.cs | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/System.Management.Automation/DscSupport/CimDSCParser.cs b/src/System.Management.Automation/DscSupport/CimDSCParser.cs index 5a38a452347..ad68c07caa1 100644 --- a/src/System.Management.Automation/DscSupport/CimDSCParser.cs +++ b/src/System.Management.Automation/DscSupport/CimDSCParser.cs @@ -668,26 +668,11 @@ public static void Initialize(Collection errors, List moduleP else { // DSC SxS scenario - //var psAssembly = Assembly.GetEntryAssembly(); var configSystemPath = Utils.DefaultPowerShellAppBase; var systemResourceRoot = Path.Combine(configSystemPath, "Configuration"); - //var inboxModulePath = "Modules\\PSDesiredStateConfiguration"; - ExecutionContext context = null; - CommandInfo commandInfo = new CmdletInfo("Get-Module", typeof(Microsoft.PowerShell.Commands.GetModuleCommand), null, null, context); - System.Management.Automation.Runspaces.Command getModuleCommand = new System.Management.Automation.Runspaces.Command(commandInfo); - var psDesiredStateConfigurationModule = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace) - .AddCommand(getModuleCommand) - .AddParameter("List", true) - .AddParameter("Name", "PSDesiredStateConfiguration") - .AddParameter("ErrorAction", ActionPreference.Ignore) - .AddParameter("WarningAction", ActionPreference.Ignore) - .AddParameter("InformationAction", ActionPreference.Ignore) - .AddParameter("Verbose", false) - .AddParameter("Debug", false) - .Invoke(); - var inboxModulePath = psDesiredStateConfigurationModule[0].Path; - - if(!Directory.Exists(systemResourceRoot)) + var inboxModulePath = "Modules\\PSDesiredStateConfiguration"; + + if (!Directory.Exists(systemResourceRoot)) { configSystemPath = Platform.GetFolderPath(Environment.SpecialFolder.System); systemResourceRoot = Path.Combine(configSystemPath, "Configuration");