diff --git a/extensions/powershell/powershell.discover.ps1 b/extensions/powershell/powershell.discover.ps1 index 91eb348c4..d8cced58a 100644 --- a/extensions/powershell/powershell.discover.ps1 +++ b/extensions/powershell/powershell.discover.ps1 @@ -74,7 +74,14 @@ function Invoke-DscResourceDiscovery { $manifests = $cache.Manifests } else { $manifests = $psPaths | ForEach-Object -Parallel { - $searchPatterns = @('*.dsc.resource.json', '*.dsc.resource.yaml', '*.dsc.resource.yml') + $searchPatterns = @( + '*.dsc.resource.json' + '*.dsc.resource.yaml' + '*.dsc.resource.yml' + '*.dsc.adaptedresource.json' + '*.dsc.adaptedresource.yaml' + '*.dsc.adaptedresource.yml' + ) $enumOptions = [System.IO.EnumerationOptions]@{ IgnoreInaccessible = $true; RecurseSubdirectories = $true } foreach ($pattern in $searchPatterns) { try { diff --git a/extensions/powershell/powershell.discover.tests.ps1 b/extensions/powershell/powershell.discover.tests.ps1 index 2b66c4bb8..540181fcb 100644 --- a/extensions/powershell/powershell.discover.tests.ps1 +++ b/extensions/powershell/powershell.discover.tests.ps1 @@ -20,6 +20,35 @@ BeforeAll { $manifestPath = Join-Path $TestDrive "fake.dsc.resource.json" $fakeManifest | ConvertTo-Json -Depth 10 | Set-Content -Path $manifestPath + + $fakeAdaptedManifest = @{ + '$schema' = "https://aka.ms/dsc/schemas/v3/bundled/adaptedresource/manifest.json" + type = "Test/FakeAdaptedResource" + kind = "resource" + version = "0.1.0" + capabilities = @("get", "set", "test") + description = "A fake adapted resource for regression testing." + requireAdapter = "Microsoft.Adapter/PowerShell" + path = "FakeAdapted.psd1" + schema = @{ + embedded = @{ + '$schema' = "https://json-schema.org/draft/2020-12/schema" + title = "Test/FakeAdaptedResource" + type = "object" + required = @("Name") + additionalProperties = $false + properties = @{ + Name = @{ type = "string"; title = "Name"; description = "The name." } + } + } + } + } + + $adaptedManifestPath = Join-Path $TestDrive "fake.dsc.adaptedresource.json" + $fakeAdaptedManifest | ConvertTo-Json -Depth 10 | Set-Content -Path $adaptedManifestPath + + $fakePsd1Path = Join-Path $TestDrive "FakeAdapted.psd1" + Set-Content -Path $fakePsd1Path -Value "@{ ModuleVersion = '0.1.0' }" $script:OldPSModulePath = $env:PSModulePath $env:PSModulePath += [System.IO.Path]::PathSeparator + $TestDrive @@ -127,4 +156,10 @@ Describe 'Tests for PowerShell resource discovery' { $out = & $script:discoverScript | ConvertFrom-Json $out.manifestPath | Should -Contain $manifestPath } + + It 'Should discover adapted resource manifest files' { + Remove-Item -Force -ErrorAction SilentlyContinue -Path $script:cacheFilePath + $out = & $script:discoverScript | ConvertFrom-Json + $out.manifestPath | Should -Contain $adaptedManifestPath + } }