Skip to content
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dd41634
Init
Gijsreyn Aug 21, 2025
9e04ed5
Use concurrentbag
Gijsreyn Aug 21, 2025
dae94e4
Use .NET
Gijsreyn Aug 21, 2025
6ec70d7
Use .NET with enumeration option
Gijsreyn Aug 21, 2025
d13045d
Init
Gijsreyn Aug 21, 2025
33b7ab2
Use concurrentbag
Gijsreyn Aug 21, 2025
f12038e
Use .NET
Gijsreyn Aug 21, 2025
991f7ce
Use .NET with enumeration option
Gijsreyn Aug 21, 2025
1e80819
Remove undiscovered resource
Gijsreyn Aug 27, 2025
6337045
Merge branch 'implement-powershell-discover' of https://github.com/Gi…
Gijsreyn Aug 27, 2025
69ef042
Init
Gijsreyn Aug 21, 2025
f7c606a
Use concurrentbag
Gijsreyn Aug 21, 2025
f93e691
Use .NET
Gijsreyn Aug 21, 2025
16bf2f5
Use .NET with enumeration option
Gijsreyn Aug 21, 2025
34375b6
Init
Gijsreyn Aug 21, 2025
16b41c4
Use concurrentbag
Gijsreyn Aug 21, 2025
3037ffe
Use .NET
Gijsreyn Aug 21, 2025
1ef6482
Use .NET with enumeration option
Gijsreyn Aug 21, 2025
f15195a
Remove undiscovered resource
Gijsreyn Aug 27, 2025
1caa83a
Merge branch 'implement-powershell-discover' of https://github.com/Gi…
Gijsreyn Sep 3, 2025
a7263ba
Fix point 2
Gijsreyn Sep 3, 2025
640c664
Add newline
Gijsreyn Sep 4, 2025
1b58423
Merge branch 'main' into implement-powershell-discover
Gijsreyn Sep 9, 2025
6992c43
Merge branch 'main' into implement-powershell-discover
Gijsreyn Sep 18, 2025
5ec950e
Merge branch 'main' into implement-powershell-discover
Gijsreyn Sep 22, 2025
c139f8a
Merge branch 'main' into implement-powershell-discover
Gijsreyn Oct 7, 2025
861a017
Add caching
Gijsreyn Oct 8, 2025
48202c7
Debug tests
Gijsreyn Oct 8, 2025
e99c662
Format file
Gijsreyn Oct 8, 2025
0dfe4cd
Revert to working situation
Gijsreyn Oct 8, 2025
ff104c2
Create function
Gijsreyn Oct 8, 2025
091e017
Catch empty value
Gijsreyn Oct 8, 2025
9b6c993
Re-add tests
Gijsreyn Oct 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ $filesForWindowsPackage = @(
'NOTICE.txt',
'osinfo.exe',
'osinfo.dsc.resource.json',
'powershell.discover.ps1',
'powershell.dsc.extension.json',
'powershell.dsc.resource.json',
'psDscAdapter/',
'psscript.ps1',
Expand Down Expand Up @@ -101,6 +103,8 @@ $filesForLinuxPackage = @(
'NOTICE.txt',
'osinfo',
'osinfo.dsc.resource.json',
'powershell.discover.ps1',
'powershell.dsc.extension.json',
'powershell.dsc.resource.json',
'psDscAdapter/',
'psscript.ps1',
Expand All @@ -126,6 +130,8 @@ $filesForMacPackage = @(
'NOTICE.txt',
'osinfo',
'osinfo.dsc.resource.json',
'powershell.discover.ps1',
'powershell.dsc.extension.json',
'powershell.dsc.resource.json',
'psDscAdapter/',
'psscript.ps1',
Expand Down Expand Up @@ -329,9 +335,9 @@ if (!$SkipBuild) {
New-Item -ItemType Directory $target -ErrorAction Ignore > $null

# make sure dependencies are built first so clippy runs correctly
$windows_projects = @("pal", "registry_lib", "registry", "reboot_pending", "wmi-adapter", "configurations/windows", 'extensions/appx')
$macOS_projects = @("resources/brew")
$linux_projects = @("resources/apt")
$windows_projects = @("pal", "registry_lib", "registry", "reboot_pending", "wmi-adapter", "configurations/windows", "extensions/appx", "extensions/powershell")
$macOS_projects = @("resources/brew", "extensions/powershell")
$linux_projects = @("resources/apt", "extensions/powershell")

# projects are in dependency order
$projects = @(
Expand Down
45 changes: 22 additions & 23 deletions dsc/tests/dsc_extension_discover.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,29 @@ Describe 'Discover extension tests' {
It 'Discover extensions' {
$out = dsc extension list | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0
if ($IsWindows) {
$out.Count | Should -Be 3 -Because ($out | Out-String)
$out[0].type | Should -Be 'Microsoft.DSC.Extension/Bicep'
$out[0].version | Should -Be '0.1.0'
$out[0].capabilities | Should -BeExactly @('import')
$out[0].manifest | Should -Not -BeNullOrEmpty
$out[1].type | Should -Be 'Microsoft.Windows.Appx/Discover'
$out[1].version | Should -Be '0.1.0'
$out[1].capabilities | Should -BeExactly @('discover')
$out[1].manifest | Should -Not -BeNullOrEmpty
$out[2].type | Should -BeExactly 'Test/Discover'
$out[2].version | Should -BeExactly '0.1.0'
$out[2].capabilities | Should -BeExactly @('discover')
$out[2].manifest | Should -Not -BeNullOrEmpty
$expectedExtensions = if ($IsWindows) {
@(
@{ type = 'Microsoft.DSC.Extension/Bicep'; version = '0.1.0'; capabilities = @('import') }
@{ type = 'Microsoft.Windows.Appx/Discover'; version = '0.1.0'; capabilities = @('discover') }
@{ type = 'Microsoft.PowerShell/Discover'; version = '0.1.0'; capabilities = @('discover') }
@{ type = 'Test/Discover'; version = '0.1.0'; capabilities = @('discover') }
)
} else {
$out.Count | Should -Be 2 -Because ($out | Out-String)
$out[0].type | Should -Be 'Microsoft.DSC.Extension/Bicep'
$out[0].version | Should -Be '0.1.0'
$out[0].capabilities | Should -BeExactly @('import')
$out[0].manifest | Should -Not -BeNullOrEmpty
$out[1].type | Should -BeExactly 'Test/Discover'
$out[1].version | Should -BeExactly '0.1.0'
$out[1].capabilities | Should -BeExactly @('discover')
$out[1].manifest | Should -Not -BeNullOrEmpty
@(
@{ type = 'Microsoft.DSC.Extension/Bicep'; version = '0.1.0'; capabilities = @('import') }
@{ type = 'Microsoft.PowerShell/Discover'; version = '0.1.0'; capabilities = @('discover') }
@{ type = 'Test/Discover'; version = '0.1.0'; capabilities = @('discover') }
)
}

$out.Count | Should -Be $expectedExtensions.Count -Because ($out | Out-String)

foreach ($expected in $expectedExtensions) {
$extension = $out | Where-Object { $_.type -eq $expected.type }
$extension | Should -Not -BeNullOrEmpty -Because "Extension $($expected.type) should exist"
$extension.version | Should -BeExactly $expected.version
$extension.capabilities | Should -BeExactly $expected.capabilities
$extension.manifest | Should -Not -BeNullOrEmpty
}
}

Expand Down
2 changes: 2 additions & 0 deletions extensions/powershell/copy_files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
powershell.discover.ps1
powershell.dsc.extension.json
25 changes: 25 additions & 0 deletions extensions/powershell/powershell.discover.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

[CmdletBinding()]
param ()

begin {
$psPaths = $env:PSModulePath -split [System.IO.Path]::PathSeparator | Where-Object { $_ -notmatch 'WindowsPowerShell' }
}
process {
$manifests = $psPaths | ForEach-Object -Parallel {
$searchPatterns = @('*.dsc.resource.json', '*.dsc.resource.yaml', '*.dsc.resource.yml')
$enumOptions = [System.IO.EnumerationOptions]@{ IgnoreInaccessible = $false; RecurseSubdirectories = $true }
foreach ($pattern in $searchPatterns) {
try {
[System.IO.Directory]::EnumerateFiles($_, $pattern, $enumOptions) | ForEach-Object {
@{ manifestPath = $_ }
}
} catch { }
}
} -ThrottleLimit 10
}
end {
$manifests | ForEach-Object { $_ | ConvertTo-Json -Compress }
}
32 changes: 32 additions & 0 deletions extensions/powershell/powershell.discover.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

BeforeAll {
$fakeManifest = @{
'$schema' = "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json"
type = "Test/FakeResource"
version = "0.1.0"
get = @{
executable = "fakeResource"
args = @(
"get",
@{
jsonInputArg = "--input"
mandatory = $true
}
)
}
}

$manifestPath = Join-Path $TestDrive "fake.dsc.resource.json"
$fakeManifest | ConvertTo-Json -Depth 10 | Set-Content -Path $manifestPath
$env:PSModulePath += [System.IO.Path]::PathSeparator + $TestDrive
}

Describe 'Tests for PowerShell resource discovery' {
It 'Should find DSC PowerShell resources' {
$out = dsc resource list | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0
$out.directory | Should -Contain $TestDrive
}
}
18 changes: 18 additions & 0 deletions extensions/powershell/powershell.dsc.extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json",
"type": "Microsoft.PowerShell/Discover",
"version": "0.1.0",
"description": "Discovers DSC resources packaged in PowerShell 7 modules.",
"discover": {
"executable": "pwsh",
"args": [
"-NoLogo",
"-NonInteractive",
"-ExecutionPolicy",
"Bypass",
"-NoProfile",
"-Command",
"./powershell.discover.ps1"
]
}
}
Loading