Skip to content

Commit 34ee536

Browse files
rkeithhilldaviwil
authored andcommitted
Don't attempt to import DSC module on PowerShell core
Also, use env var for ProgramFiles location.
1 parent 5a110b4 commit 34ee536

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/PowerShellEditorServices/Session/Capabilities/DscBreakpointCapability.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,17 @@ public static DscBreakpointCapability CheckForCapability(
8484
{
8585
DscBreakpointCapability capability = null;
8686

87-
if (runspaceDetails.Context != RunspaceContext.DebuggedRunspace)
87+
// DSC support is enabled only for Windows PowerShell.
88+
if ((runspaceDetails.PowerShellVersion.Version.Major < 6) &&
89+
(runspaceDetails.Context != RunspaceContext.DebuggedRunspace))
8890
{
8991
using (PowerShell powerShell = PowerShell.Create())
9092
{
9193
powerShell.Runspace = runspaceDetails.Runspace;
9294

9395
// Attempt to import the updated DSC module
9496
powerShell.AddCommand("Import-Module");
95-
powerShell.AddArgument(@"C:\Program Files\DesiredStateConfiguration\1.0.0.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psd1");
97+
powerShell.AddArgument(@"${env:ProgramFiles}\DesiredStateConfiguration\1.0.0.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psd1");
9698
powerShell.AddParameter("PassThru");
9799
powerShell.AddParameter("ErrorAction", "Ignore");
98100

0 commit comments

Comments
 (0)