diff --git a/build.proj b/build.proj index 628e8d30fe68..185706ca2946 100644 --- a/build.proj +++ b/build.proj @@ -263,6 +263,8 @@ + + @@ -353,4 +355,4 @@ $(RepoArtifacts)/$(Configuration)/**/Microsoft.Azure.PowerShell.Authenticators.d - \ No newline at end of file + diff --git a/tools/CompleteOutputTypeIndex.ps1 b/tools/CompleteOutputTypeIndex.ps1 new file mode 100644 index 000000000000..e88aac8e0a47 --- /dev/null +++ b/tools/CompleteOutputTypeIndex.ps1 @@ -0,0 +1,58 @@ +param( + [Parameter(Mandatory = $false)] + [string] $BuildConfig = "Release", + [Parameter(Mandatory = $false)] + [string] $OutputFile = "outputtypes.json" +) +Install-Module Az.Accounts -Repository PSGallery -Force -Scope CurrentUser +$AzPreviewPath = Get-Item $PSScriptRoot\AzPreview\AzPreview.psd1 +Import-LocalizedData -BindingVariable ModuleMetadata -BaseDirectory $AzPreviewPath.DirectoryName -FileName $AzPreviewPath.Name +$ModulePath = ($env:PSModulePath -split ';')[0] +$outputTypes = New-Object System.Collections.Generic.HashSet[string] +$jsonData = Get-Content $OutputFile | ConvertFrom-Json +$ProjectPaths = @( "$PSScriptRoot\..\src" ) +$ModuleManifestFile = $ProjectPaths | % { Get-ChildItem -Path $_ -Filter "*.psd1" -Recurse | where {$_.FullName -notlike "*autorest*"}} +foreach ($item in $jsonData) { + $outputTypes.Add($item) | Out-Null +} +$ModuleMetadata.RequiredModules | ForEach { + $ModuleName = $_.ModuleName + $RequiredVersion = $_.RequiredVersion + $srcFile = $ModuleManifestFile | Where-Object {$_.Name -eq "$ModuleName.psd1"} + Import-LocalizedData -BindingVariable srcMetadata -BaseDirectory $srcFile.DirectoryName -FileName $srcFile.Name + $containsPsd1 = $srcMetadata.NestedModules | Where-Object { $_ -like "*.dll" } + $DestinationModulePath = [System.IO.Path]::Combine($ModulePath, $ModuleName, $RequiredVersion) + $psd1Path = Join-Path -Path $DestinationModulePath -ChildPath "$ModuleName.psd1" + if (($containsPsd1.count -gt 0) -and (Test-Path $psd1Path)){ + Import-Module $Psd1Path -Force + $Module = Get-Module $ModuleName + foreach ($ModuleInfo in $Module.NestedModules){ + if ($srcMetadata.NestedModules -contains $ModuleInfo.Name+".dll") { + foreach ($Cmdlet in $ModuleInfo.ExportedCmdlets.Values) { + $OutputAttributeList = $Cmdlet.ImplementingType.GetTypeInfo().GetCustomAttributes([System.Management.Automation.OutputTypeAttribute], $true) + foreach ($OutputAttribute in $OutputAttributeList) + { + foreach ($OutputType in $OutputAttribute.Type) + { + $outputTypes.Add($OutputType.Name) | Out-Null + } + } + foreach ($Parameter in $Cmdlet.Parameters.Values){ + if ($Parameter.Attributes.TypeId.FullName -contains "System.Management.Automation.ParameterAttribute") { + if ($Parameter.ParameterType.FullName -like "*System.Nullable*``[``[*") + { + $outputTypes.Add(($Parameter.ParameterType.BaseType.FullName -replace "[][]", "")) | Out-Null + } + elseif ($Parameter.ParameterType.FullName -notlike "*``[``[*") + { + $outputTypes.Add(($Parameter.ParameterType.FullName -replace "[][]", "")) | Out-Null + } + } + } + } + } + } + } + } +$json = ConvertTo-Json $outputTypes +$json | Out-File "$OutputFile" diff --git a/tools/NewHelpIndex.ps1 b/tools/NewHelpIndex.ps1 index 1c0c05a2b665..15219e3e29c7 100644 --- a/tools/NewHelpIndex.ps1 +++ b/tools/NewHelpIndex.ps1 @@ -63,15 +63,15 @@ $outputModules = @{} & "$PSScriptRoot/CreateMappings.ps1" -OutputFile $OutputFile/../groupMapping.json -WarningFile $OutputFile/../groupMappingWarnings.json $labelMapping = Get-Content -Raw $OutputFile/../groupMapping.json | ConvertFrom-Json -$RMpsd1s = @() $HelpFolders = @() - -$resourceManagerPath = "$PSScriptRoot/../artifacts/$BuildConfig/" - -$RMpsd1s += Get-ChildItem -Path $resourceManagerPath -Depth 1 | Where-Object { - $_.Name -like "*.psd1" -and $_.FullName -notlike "*dll-Help*" -} - +$ProjectPaths = @( "$PSScriptRoot/../src") +$RMpsd1s = $ProjectPaths | % { Get-ChildItem -Path $_ -Filter "*.psd1" -Recurse | where { + $_.FullName -inotlike "*autorest*" -and ` + $_.FullName -inotlike "*extension*" -and ` + $_.FullName -notlike "*Debug*" -and ` + $_.FullName -notlike "*Netcore*" -and ` + $_.FullName -notlike "*dll-Help.psd1*" -and ` + (-not [Tools.Common.Utilities.ModuleFilter]::IsAzureStackModule($_.FullName)) } } .($PSScriptRoot + "\PreloadToolDll.ps1") $HelpFolders += Get-ChildItem -Path "$PSScriptRoot/../src" -Recurse -Directory | where { $_.Name -eq "help" -and (-not [Tools.Common.Utilities.ModuleFilter]::IsAzureStackModule($_.FullName)) -and $_.FullName -notlike "*\bin\*" -and (-not $_.Parent.BaseName.EndsWith(".Autorest", "CurrentCultureIgnoreCase"))}