1+ param (
2+ [Parameter (Mandatory = $false )]
3+ [string ] $BuildConfig = " Debug" ,
4+ [Parameter (Mandatory = $false )]
5+ [string ] $OutputFile = " $PSScriptRoot /outputtypes.json"
6+ )
7+
8+ # Get all psd1 files
9+ $psd1Files = Get-Childitem $PSScriptRoot \..\src\Package\$BuildConfig \ResourceManager - Recurse | where {$_.Name -like " *.psd1" }
10+ $psd1Files += Get-Childitem $PSScriptRoot \..\src\Package\$BuildConfig \Storage - Recurse | where {$_.Name -like " *.psd1" }
11+
12+ $profilePsd1 = $psd1Files | Where-Object {$_.Name -like " *AzureRM.Profile.psd1" }
13+ Import-LocalizedData - BindingVariable " psd1File" - BaseDirectory $profilePsd1.DirectoryName - FileName $profilePsd1.Name
14+ foreach ($nestedModule in $psd1File.RequiredAssemblies )
15+ {
16+ $dllPath = Join-Path - Path $profilePsd1.DirectoryName - ChildPath $nestedModule
17+ $Assembly = [Reflection.Assembly ]::LoadFrom($dllPath )
18+ }
19+
20+
21+ $outputTypes = New-Object System.Collections.Generic.HashSet[string ]
22+
23+ $psd1Files | ForEach {
24+ Import-LocalizedData - BindingVariable " psd1File" - BaseDirectory $_.DirectoryName - FileName $_.Name
25+ foreach ($nestedModule in $psd1File.NestedModules )
26+ {
27+ $dllPath = Join-Path - Path $_.DirectoryName - ChildPath $nestedModule
28+ $Assembly = [Reflection.Assembly ]::LoadFrom($dllPath )
29+ $exportedTypes = $Assembly.GetTypes ()
30+ foreach ($exportedType in $exportedTypes )
31+ {
32+ foreach ($attribute in $exportedType.CustomAttributes )
33+ {
34+ if ($attribute.AttributeType.Name -eq " OutputTypeAttribute" )
35+ {
36+ $cmdletOutputTypes = $attribute.ConstructorArguments.Value.Value
37+ foreach ($cmdletOutputType in $cmdletOutputTypes )
38+ {
39+ $outputTypes.Add ($cmdletOutputType.FullName ) | Out-Null
40+ }
41+ }
42+ }
43+ }
44+ }
45+ }
46+
47+ $json = ConvertTo-Json $outputTypes
48+ $json | Out-File " $OutputFile "
0 commit comments