From 40f663ccb26f149a015a60e03630731245c30065 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 10 May 2025 08:32:54 +0200 Subject: [PATCH 01/16] Add Bicep example --- dsc/examples/file.bicep | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 dsc/examples/file.bicep diff --git a/dsc/examples/file.bicep b/dsc/examples/file.bicep new file mode 100644 index 000000000..d435f3535 --- /dev/null +++ b/dsc/examples/file.bicep @@ -0,0 +1,22 @@ +// This example demonstrates how to create a file using the Windows PowerShell DSC extension. +// The file is created in the C:\DSC directory on the target machine. +// You should at least have the Bicep CLI v0.34.34 installed to run this example with experimental feature desiredStateConfiguration turned on. + +targetScope = 'desiredStateConfiguration' + +resource powerShellAdapter 'Microsoft.Windows/WindowsPowerShell@2025-01-07' = { + name: 'Use Bicep to create file' + properties: { + resources: [ + { + name: 'File' + type: 'PSDesiredStateConfiguration/File' + properties: { + Ensure: 'Present' + Type: 'Directory' + DestinationPath: 'C:\\DSC\\' + } + } + ] + } +} From 159fe7cbeda1708c1cef78442faa7669ae55d4e3 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 10 May 2025 08:35:55 +0200 Subject: [PATCH 02/16] Call Bicep --- dsc/examples/file.bicep | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dsc/examples/file.bicep b/dsc/examples/file.bicep index d435f3535..28e082adb 100644 --- a/dsc/examples/file.bicep +++ b/dsc/examples/file.bicep @@ -20,3 +20,5 @@ resource powerShellAdapter 'Microsoft.Windows/WindowsPowerShell@2025-01-07' = { ] } } + +// bicep build file.bicep From d6f044ab1523b0c7cfede99ac7bbee8c30d8f5f9 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 10 May 2025 08:32:54 +0200 Subject: [PATCH 03/16] Add Bicep example --- dsc/examples/file.bicep | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 dsc/examples/file.bicep diff --git a/dsc/examples/file.bicep b/dsc/examples/file.bicep new file mode 100644 index 000000000..d435f3535 --- /dev/null +++ b/dsc/examples/file.bicep @@ -0,0 +1,22 @@ +// This example demonstrates how to create a file using the Windows PowerShell DSC extension. +// The file is created in the C:\DSC directory on the target machine. +// You should at least have the Bicep CLI v0.34.34 installed to run this example with experimental feature desiredStateConfiguration turned on. + +targetScope = 'desiredStateConfiguration' + +resource powerShellAdapter 'Microsoft.Windows/WindowsPowerShell@2025-01-07' = { + name: 'Use Bicep to create file' + properties: { + resources: [ + { + name: 'File' + type: 'PSDesiredStateConfiguration/File' + properties: { + Ensure: 'Present' + Type: 'Directory' + DestinationPath: 'C:\\DSC\\' + } + } + ] + } +} From 97cfa4b4d9c9cb4c55d939a2cdd8f4b9d1fccf72 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 10 May 2025 08:35:55 +0200 Subject: [PATCH 04/16] Call Bicep --- dsc/examples/file.bicep | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dsc/examples/file.bicep b/dsc/examples/file.bicep index d435f3535..28e082adb 100644 --- a/dsc/examples/file.bicep +++ b/dsc/examples/file.bicep @@ -20,3 +20,5 @@ resource powerShellAdapter 'Microsoft.Windows/WindowsPowerShell@2025-01-07' = { ] } } + +// bicep build file.bicep From 07b332fb6b384972c3fc300775a065994bc80329 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Tue, 29 Jul 2025 02:58:45 +0200 Subject: [PATCH 05/16] Update example --- dsc/examples/file.bicep | 24 -------------- dsc/examples/file_with_condition.dsc.bicep | 38 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 24 deletions(-) delete mode 100644 dsc/examples/file.bicep create mode 100644 dsc/examples/file_with_condition.dsc.bicep diff --git a/dsc/examples/file.bicep b/dsc/examples/file.bicep deleted file mode 100644 index 28e082adb..000000000 --- a/dsc/examples/file.bicep +++ /dev/null @@ -1,24 +0,0 @@ -// This example demonstrates how to create a file using the Windows PowerShell DSC extension. -// The file is created in the C:\DSC directory on the target machine. -// You should at least have the Bicep CLI v0.34.34 installed to run this example with experimental feature desiredStateConfiguration turned on. - -targetScope = 'desiredStateConfiguration' - -resource powerShellAdapter 'Microsoft.Windows/WindowsPowerShell@2025-01-07' = { - name: 'Use Bicep to create file' - properties: { - resources: [ - { - name: 'File' - type: 'PSDesiredStateConfiguration/File' - properties: { - Ensure: 'Present' - Type: 'Directory' - DestinationPath: 'C:\\DSC\\' - } - } - ] - } -} - -// bicep build file.bicep diff --git a/dsc/examples/file_with_condition.dsc.bicep b/dsc/examples/file_with_condition.dsc.bicep new file mode 100644 index 000000000..98ac6b9cb --- /dev/null +++ b/dsc/examples/file_with_condition.dsc.bicep @@ -0,0 +1,38 @@ +// This example demonstrates how to create a file using the Windows PowerShell DSC extension. +// The file is created in the C:\DSC directory on the target machine. +// You should at least have the Bicep CLI v0.34.34 installed to run this example with experimental feature desiredStateConfiguration turned on. +// To run the second resource, you can add the --parameters '{"parameters":{"restartService":true}}' flag to the command line. + +targetScope = 'desiredStateConfiguration' + +@description('Set to true to ensure the service is running after the file creation.') +param restartService bool = false + +resource powerShellAdapter 'Microsoft.Windows/WindowsPowerShell@2025-01-07' = { + name: 'Use Bicep to create file' + properties: { + resources: [ + { + name: 'File' + type: 'PSDesiredStateConfiguration/File' + properties: { + Ensure: 'Present' + Type: 'File' + DestinationPath: 'C:\\DSC\\config.txt' + Contents: 'This file was created using Bicep extension from DSC.' + } + } + ] + } +} + +// Optionally ensure the service is running after the file creation +resource ensureServiceRunning 'PSDesiredStateConfiguration/Service@2025-01-07' = if (restartService) { + name: 'Ensure DSC service is running' + properties: { + Name: 'Spooler' + StartupType: 'Automatic' + State: 'Running' + } +} + From 261879119b365a4442042f85dbea89ed936e96e7 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Wed, 30 Jul 2025 01:44:06 +0200 Subject: [PATCH 06/16] Add test --- extensions/bicep/bicep.tests.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/extensions/bicep/bicep.tests.ps1 b/extensions/bicep/bicep.tests.ps1 index a60e65cd7..ba3ccac59 100644 --- a/extensions/bicep/bicep.tests.ps1 +++ b/extensions/bicep/bicep.tests.ps1 @@ -34,4 +34,13 @@ resource invalid 'Microsoft.DSC.Extension/Bicep:1.0' = { $content | Should -Match "Importing file '$bicepFile' with extension 'Microsoft.DSC.Extension/Bicep'" $content | Should -Match "BCP033" } + + It 'Example bicep file with condition works' -Skip:(!$foundBicep -and !$IsWindows) { + $params = @{ parameters = @{ restartService = $true } } | ConvertTo-Json -Compress + $bicepFile = Resolve-Path -Path "$PSScriptRoot\..\..\dsc\examples\file_with_condition.dsc.bicep" + $out = dsc config --parameters $params get -f $bicepFile 2>$TestDrive/error.log | ConvertFrom-Json + $LASTEXITCODE | Should -Be 0 -Because (Get-Content -Path $TestDrive/error.log -Raw | Out-String) + $out.results[0].result.actualState.result.properties.Ensure | Should -Be 'Absent' # As set is not called + $out.results[1].result.actualState.StartupType | Should -Be 'Automatic' + } } From 798a77f84a63199757e9772807162bcb8b09cb45 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Wed, 30 Jul 2025 02:03:20 +0200 Subject: [PATCH 07/16] Fix condition --- extensions/bicep/bicep.tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/bicep/bicep.tests.ps1 b/extensions/bicep/bicep.tests.ps1 index ba3ccac59..a59b7006e 100644 --- a/extensions/bicep/bicep.tests.ps1 +++ b/extensions/bicep/bicep.tests.ps1 @@ -35,7 +35,7 @@ resource invalid 'Microsoft.DSC.Extension/Bicep:1.0' = { $content | Should -Match "BCP033" } - It 'Example bicep file with condition works' -Skip:(!$foundBicep -and !$IsWindows) { + It 'Example bicep file with condition works' -Skip:(!$foundBicep -or !$IsWindows) { $params = @{ parameters = @{ restartService = $true } } | ConvertTo-Json -Compress $bicepFile = Resolve-Path -Path "$PSScriptRoot\..\..\dsc\examples\file_with_condition.dsc.bicep" $out = dsc config --parameters $params get -f $bicepFile 2>$TestDrive/error.log | ConvertFrom-Json From 6e112167eeef50fdd77be5ed395164d9e419c994 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 9 Aug 2025 08:35:27 +0200 Subject: [PATCH 08/16] Implicit vs explicit --- dsc/examples/file_with_condition.dsc.bicep | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/dsc/examples/file_with_condition.dsc.bicep b/dsc/examples/file_with_condition.dsc.bicep index 98ac6b9cb..c01e37a29 100644 --- a/dsc/examples/file_with_condition.dsc.bicep +++ b/dsc/examples/file_with_condition.dsc.bicep @@ -2,28 +2,22 @@ // The file is created in the C:\DSC directory on the target machine. // You should at least have the Bicep CLI v0.34.34 installed to run this example with experimental feature desiredStateConfiguration turned on. // To run the second resource, you can add the --parameters '{"parameters":{"restartService":true}}' flag to the command line. +// The configuration document requires to be run elevated. +// From dsc version 3.2.0-preview.4 and above onwards, you can directly run the example using `dsc config get --file file_with_condition.dsc.bicep`. targetScope = 'desiredStateConfiguration' @description('Set to true to ensure the service is running after the file creation.') param restartService bool = false -resource powerShellAdapter 'Microsoft.Windows/WindowsPowerShell@2025-01-07' = { +resource powerShellAdapter 'PSDesiredStateConfiguration/File@2025-01-07' = { name: 'Use Bicep to create file' properties: { - resources: [ - { - name: 'File' - type: 'PSDesiredStateConfiguration/File' - properties: { - Ensure: 'Present' - Type: 'File' - DestinationPath: 'C:\\DSC\\config.txt' - Contents: 'This file was created using Bicep extension from DSC.' - } - } - ] - } + Ensure: 'Present' + Type: 'File' + DestinationPath: 'C:\\DSC\\config.txt' + Contents: 'This file was created using Bicep extension from DSC.' + } } // Optionally ensure the service is running after the file creation From b77b2fdc12a544d9b24033e2935eb98c94231ac6 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 9 Aug 2025 11:18:11 +0200 Subject: [PATCH 09/16] Debug rewrite build script --- build.ps1 | 4 ++++ dsc/examples/file_with_condition.dsc.bicep | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 5cb6b3922..3f300b809 100755 --- a/build.ps1 +++ b/build.ps1 @@ -166,6 +166,10 @@ if ($null -ne (Get-Command msrustup -CommandType Application -ErrorAction Ignore $rustup = 'echo' } +if ($IsWindows) { + Get-Module -ListAvailable PSDesiredStateConfiguration +} + if ($null -ne $packageType) { $SkipBuild = $true } else { diff --git a/dsc/examples/file_with_condition.dsc.bicep b/dsc/examples/file_with_condition.dsc.bicep index c01e37a29..9ddcdd602 100644 --- a/dsc/examples/file_with_condition.dsc.bicep +++ b/dsc/examples/file_with_condition.dsc.bicep @@ -15,7 +15,7 @@ resource powerShellAdapter 'PSDesiredStateConfiguration/File@2025-01-07' = { properties: { Ensure: 'Present' Type: 'File' - DestinationPath: 'C:\\DSC\\config.txt' + DestinationPath: '${systemroot()}\\DSC\\config.txt' Contents: 'This file was created using Bicep extension from DSC.' } } From d2c9cd3158caf54419bc02fc576949bc694f72c9 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 9 Aug 2025 11:22:05 +0200 Subject: [PATCH 10/16] Add verbose message --- build.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 3f300b809..b3e206040 100755 --- a/build.ps1 +++ b/build.ps1 @@ -167,7 +167,9 @@ if ($null -ne (Get-Command msrustup -CommandType Application -ErrorAction Ignore } if ($IsWindows) { - Get-Module -ListAvailable PSDesiredStateConfiguration + $s = Get-Module -ListAvailable PSDesiredStateConfiguration + Write-Verbose -Message "Got $($s.Count) PSDesiredStateConfiguration modules" -Verbose + Write-Verbose ($s | ConvertTo-Json | Out-String) -Verbose } if ($null -ne $packageType) { From 20af2f036bec3786f287ddc5022f6675a9a962b6 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 9 Aug 2025 11:28:15 +0200 Subject: [PATCH 11/16] Run under powershell --- .github/workflows/rust.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fea5d9475..ed63fedcd 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -50,6 +50,10 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Test + shell: powershell + run: | + Get-Module -ListAvailable PSDesiredStateConfiguration - name: Build shell: pwsh run: ./build.ps1 -clippy From 63ae08495bd162b035c32e0e45dafe3b66bf9a73 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 9 Aug 2025 11:36:42 +0200 Subject: [PATCH 12/16] Debug module path --- .github/workflows/rust.yml | 4 ---- build.ps1 | 6 ------ extensions/bicep/bicep.tests.ps1 | 2 ++ 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ed63fedcd..fea5d9475 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -50,10 +50,6 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Test - shell: powershell - run: | - Get-Module -ListAvailable PSDesiredStateConfiguration - name: Build shell: pwsh run: ./build.ps1 -clippy diff --git a/build.ps1 b/build.ps1 index b3e206040..5cb6b3922 100755 --- a/build.ps1 +++ b/build.ps1 @@ -166,12 +166,6 @@ if ($null -ne (Get-Command msrustup -CommandType Application -ErrorAction Ignore $rustup = 'echo' } -if ($IsWindows) { - $s = Get-Module -ListAvailable PSDesiredStateConfiguration - Write-Verbose -Message "Got $($s.Count) PSDesiredStateConfiguration modules" -Verbose - Write-Verbose ($s | ConvertTo-Json | Out-String) -Verbose -} - if ($null -ne $packageType) { $SkipBuild = $true } else { diff --git a/extensions/bicep/bicep.tests.ps1 b/extensions/bicep/bicep.tests.ps1 index 763706ec5..8a9779a98 100644 --- a/extensions/bicep/bicep.tests.ps1 +++ b/extensions/bicep/bicep.tests.ps1 @@ -38,6 +38,8 @@ resource invalid 'Microsoft.DSC.Extension/Bicep:1.0' = { } It 'Example bicep file with condition works' -Skip:(!$foundBicep -or !$IsWindows) { + Write-Verbose -Message $env:PSModulePath -Verbose + $params = @{ parameters = @{ restartService = $true } } | ConvertTo-Json -Compress $bicepFile = Resolve-Path -Path "$PSScriptRoot\..\..\dsc\examples\file_with_condition.dsc.bicep" $out = dsc config --parameters $params get -f $bicepFile 2>$TestDrive/error.log | ConvertFrom-Json From 210684be694142a35ee7ea02b1eee472a5707422 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 9 Aug 2025 12:47:49 +0200 Subject: [PATCH 13/16] Reduce build time and only test for bicep --- build.ps1 | 10 +++++++++- extensions/bicep/bicep.tests.ps1 | 8 ++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5cb6b3922..7569859b2 100755 --- a/build.ps1 +++ b/build.ps1 @@ -574,7 +574,15 @@ if ($Test) { (Get-Module -Name Pester -ListAvailable).Path } - Invoke-Pester -Output Detailed -ErrorAction Stop + if ($IsWindows) { + $path = Get-ChildItem -Filter bicep.tests.ps1 -Recurse + Invoke-Pester -Output Detailed -ErrorAction Stop -Path $path + } + else { + Invoke-Pester -Output Detailed -ErrorAction Stop + } + + # Invoke-Pester -Output Detailed -ErrorAction Stop } function Find-MakeAppx() { diff --git a/extensions/bicep/bicep.tests.ps1 b/extensions/bicep/bicep.tests.ps1 index 8a9779a98..736796f5a 100644 --- a/extensions/bicep/bicep.tests.ps1 +++ b/extensions/bicep/bicep.tests.ps1 @@ -38,11 +38,15 @@ resource invalid 'Microsoft.DSC.Extension/Bicep:1.0' = { } It 'Example bicep file with condition works' -Skip:(!$foundBicep -or !$IsWindows) { - Write-Verbose -Message $env:PSModulePath -Verbose + Write-Verbose -Message (Get-Module -Name PSDesiredStateConfiguration -ListAvailable | Select -ExpandProperty Path) -Verbose + + foreach ($module in (Get-ChildItem "$env:SystemRoot\System32\WindowsPowerShell\v1.0\Modules").Name) { + Write-Verbose -Message "Found module: $module" -Verbose + } $params = @{ parameters = @{ restartService = $true } } | ConvertTo-Json -Compress $bicepFile = Resolve-Path -Path "$PSScriptRoot\..\..\dsc\examples\file_with_condition.dsc.bicep" - $out = dsc config --parameters $params get -f $bicepFile 2>$TestDrive/error.log | ConvertFrom-Json + $out = dsc -l trace config --parameters $params get -f $bicepFile 2>$TestDrive/error.log | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 -Because (Get-Content -Path $TestDrive/error.log -Raw | Out-String) $out.results[0].result.actualState.result.properties.Ensure | Should -Be 'Absent' # As set is not called $out.results[1].result.actualState.StartupType | Should -Be 'Automatic' From 3dd00e4b51e7ae0ca3cdee8b7ba04baff9cf785e Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 9 Aug 2025 13:13:28 +0200 Subject: [PATCH 14/16] Remove function call --- build.ps1 | 2 +- dsc/examples/file_with_condition.dsc.bicep | 2 +- extensions/bicep/bicep.tests.ps1 | 6 ------ 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/build.ps1 b/build.ps1 index 7569859b2..2de9f4ca3 100755 --- a/build.ps1 +++ b/build.ps1 @@ -582,7 +582,7 @@ if ($Test) { Invoke-Pester -Output Detailed -ErrorAction Stop } - # Invoke-Pester -Output Detailed -ErrorAction Stop + Invoke-Pester -Output Detailed -ErrorAction Stop } function Find-MakeAppx() { diff --git a/dsc/examples/file_with_condition.dsc.bicep b/dsc/examples/file_with_condition.dsc.bicep index 9ddcdd602..c01e37a29 100644 --- a/dsc/examples/file_with_condition.dsc.bicep +++ b/dsc/examples/file_with_condition.dsc.bicep @@ -15,7 +15,7 @@ resource powerShellAdapter 'PSDesiredStateConfiguration/File@2025-01-07' = { properties: { Ensure: 'Present' Type: 'File' - DestinationPath: '${systemroot()}\\DSC\\config.txt' + DestinationPath: 'C:\\DSC\\config.txt' Contents: 'This file was created using Bicep extension from DSC.' } } diff --git a/extensions/bicep/bicep.tests.ps1 b/extensions/bicep/bicep.tests.ps1 index 736796f5a..7f3a82d8e 100644 --- a/extensions/bicep/bicep.tests.ps1 +++ b/extensions/bicep/bicep.tests.ps1 @@ -38,12 +38,6 @@ resource invalid 'Microsoft.DSC.Extension/Bicep:1.0' = { } It 'Example bicep file with condition works' -Skip:(!$foundBicep -or !$IsWindows) { - Write-Verbose -Message (Get-Module -Name PSDesiredStateConfiguration -ListAvailable | Select -ExpandProperty Path) -Verbose - - foreach ($module in (Get-ChildItem "$env:SystemRoot\System32\WindowsPowerShell\v1.0\Modules").Name) { - Write-Verbose -Message "Found module: $module" -Verbose - } - $params = @{ parameters = @{ restartService = $true } } | ConvertTo-Json -Compress $bicepFile = Resolve-Path -Path "$PSScriptRoot\..\..\dsc\examples\file_with_condition.dsc.bicep" $out = dsc -l trace config --parameters $params get -f $bicepFile 2>$TestDrive/error.log | ConvertFrom-Json From 79a8a9f24f171a023ed734e354ab9a2fcd5db821 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 9 Aug 2025 13:44:25 +0200 Subject: [PATCH 15/16] Verbose output --- .vscode/launch.json | 78 ++++++++++++++++---------------- extensions/bicep/bicep.tests.ps1 | 3 +- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index c0fe66904..00879d03f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,39 +1,39 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "lldb", - "request": "launch", - "name": "Debug config", - "program": "${workspaceFolder}/config/target/debug/config", - "args": [ - "list", - "r*" - ], - "cwd": "${workspaceFolder}" - }, - { - "name": "(macOS) Attach", - "type": "lldb", - "request": "attach", - "pid": "${command:pickMyProcess}", - }, - { - "name": "(Windows) Attach", - "type": "cppvsdbg", - "request": "attach", - "processId": "${command:pickProcess}", - }, - { - "name": "Debug sshdconfig", - "type": "cppvsdbg", - "request": "launch", - "program": "${workspaceFolder}/sshdconfig/target/debug/sshdconfig.exe", - "args": ["get"], - "cwd": "${workspaceFolder}" - } - ] -} +// { +// // Use IntelliSense to learn about possible attributes. +// // Hover to view descriptions of existing attributes. +// // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 +// "version": "0.2.0", +// "configurations": [ +// { +// "type": "lldb", +// "request": "launch", +// "name": "Debug config", +// "program": "${workspaceFolder}/config/target/debug/config", +// "args": [ +// "list", +// "r*" +// ], +// "cwd": "${workspaceFolder}" +// }, +// { +// "name": "(macOS) Attach", +// "type": "lldb", +// "request": "attach", +// "pid": "${command:pickMyProcess}", +// }, +// { +// "name": "(Windows) Attach", +// "type": "cppvsdbg", +// "request": "attach", +// "processId": "${command:pickProcess}", +// }, +// { +// "name": "Debug sshdconfig", +// "type": "cppvsdbg", +// "request": "launch", +// "program": "${workspaceFolder}/sshdconfig/target/debug/sshdconfig.exe", +// "args": ["get"], +// "cwd": "${workspaceFolder}" +// } +// ] +// } diff --git a/extensions/bicep/bicep.tests.ps1 b/extensions/bicep/bicep.tests.ps1 index 7f3a82d8e..900cd2647 100644 --- a/extensions/bicep/bicep.tests.ps1 +++ b/extensions/bicep/bicep.tests.ps1 @@ -42,7 +42,8 @@ resource invalid 'Microsoft.DSC.Extension/Bicep:1.0' = { $bicepFile = Resolve-Path -Path "$PSScriptRoot\..\..\dsc\examples\file_with_condition.dsc.bicep" $out = dsc -l trace config --parameters $params get -f $bicepFile 2>$TestDrive/error.log | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 -Because (Get-Content -Path $TestDrive/error.log -Raw | Out-String) - $out.results[0].result.actualState.result.properties.Ensure | Should -Be 'Absent' # As set is not called + Write-Verbose -Message "Output: $($out | ConvertTo-Json -Depth 10)" -Verbose + $out.results[0].result.actualState.Ensure | Should -Be 'Absent' # As set is not called $out.results[1].result.actualState.StartupType | Should -Be 'Automatic' } } From bf0ed8f586e8c69d2ab4f0eb6198510dd7f10bb4 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 9 Aug 2025 14:10:55 +0200 Subject: [PATCH 16/16] Fix test --- .vscode/launch.json | 78 ++++++++++++++++---------------- build.ps1 | 8 ---- extensions/bicep/bicep.tests.ps1 | 1 - 3 files changed, 39 insertions(+), 48 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 00879d03f..c0fe66904 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,39 +1,39 @@ -// { -// // Use IntelliSense to learn about possible attributes. -// // Hover to view descriptions of existing attributes. -// // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 -// "version": "0.2.0", -// "configurations": [ -// { -// "type": "lldb", -// "request": "launch", -// "name": "Debug config", -// "program": "${workspaceFolder}/config/target/debug/config", -// "args": [ -// "list", -// "r*" -// ], -// "cwd": "${workspaceFolder}" -// }, -// { -// "name": "(macOS) Attach", -// "type": "lldb", -// "request": "attach", -// "pid": "${command:pickMyProcess}", -// }, -// { -// "name": "(Windows) Attach", -// "type": "cppvsdbg", -// "request": "attach", -// "processId": "${command:pickProcess}", -// }, -// { -// "name": "Debug sshdconfig", -// "type": "cppvsdbg", -// "request": "launch", -// "program": "${workspaceFolder}/sshdconfig/target/debug/sshdconfig.exe", -// "args": ["get"], -// "cwd": "${workspaceFolder}" -// } -// ] -// } +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug config", + "program": "${workspaceFolder}/config/target/debug/config", + "args": [ + "list", + "r*" + ], + "cwd": "${workspaceFolder}" + }, + { + "name": "(macOS) Attach", + "type": "lldb", + "request": "attach", + "pid": "${command:pickMyProcess}", + }, + { + "name": "(Windows) Attach", + "type": "cppvsdbg", + "request": "attach", + "processId": "${command:pickProcess}", + }, + { + "name": "Debug sshdconfig", + "type": "cppvsdbg", + "request": "launch", + "program": "${workspaceFolder}/sshdconfig/target/debug/sshdconfig.exe", + "args": ["get"], + "cwd": "${workspaceFolder}" + } + ] +} diff --git a/build.ps1 b/build.ps1 index 2de9f4ca3..5cb6b3922 100755 --- a/build.ps1 +++ b/build.ps1 @@ -574,14 +574,6 @@ if ($Test) { (Get-Module -Name Pester -ListAvailable).Path } - if ($IsWindows) { - $path = Get-ChildItem -Filter bicep.tests.ps1 -Recurse - Invoke-Pester -Output Detailed -ErrorAction Stop -Path $path - } - else { - Invoke-Pester -Output Detailed -ErrorAction Stop - } - Invoke-Pester -Output Detailed -ErrorAction Stop } diff --git a/extensions/bicep/bicep.tests.ps1 b/extensions/bicep/bicep.tests.ps1 index 900cd2647..5de77e607 100644 --- a/extensions/bicep/bicep.tests.ps1 +++ b/extensions/bicep/bicep.tests.ps1 @@ -42,7 +42,6 @@ resource invalid 'Microsoft.DSC.Extension/Bicep:1.0' = { $bicepFile = Resolve-Path -Path "$PSScriptRoot\..\..\dsc\examples\file_with_condition.dsc.bicep" $out = dsc -l trace config --parameters $params get -f $bicepFile 2>$TestDrive/error.log | ConvertFrom-Json $LASTEXITCODE | Should -Be 0 -Because (Get-Content -Path $TestDrive/error.log -Raw | Out-String) - Write-Verbose -Message "Output: $($out | ConvertTo-Json -Depth 10)" -Verbose $out.results[0].result.actualState.Ensure | Should -Be 'Absent' # As set is not called $out.results[1].result.actualState.StartupType | Should -Be 'Automatic' }