Skip to content

Commit

Permalink
fix outputype and index json
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickcandy committed Jan 21, 2024
1 parent 8a06cd0 commit 11337fd
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 9 deletions.
4 changes: 3 additions & 1 deletion build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@

<Error Condition="'$(NuGetKey)' == ''" Text="You must provide the NuGetKey parameter to the build: /p:NuGetKey=YOUR_PUBLISHING_KEY" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/PublishModules.ps1 -IsNetCore:$$(NetCore) -BuildConfig $(Configuration) -Scope $(Scope) -ApiKey $(NuGetKey) -RepositoryLocation \&quot;$(NuGetPublishingSource)\&quot;&quot; -NugetExe $(NuGetCommand)" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/CompleteOutputTypeIndex.ps1 -OutputFile $(RepoArtifacts)/outputtypes.json -BuildConfig $(Configuration)&quot;"/>

</Target>

<Target Name="BuildInstaller" AfterTargets="Publish" Condition="('$(Scope)' == 'All' or '$(Scope)' == 'Latest' or '$(Scope)' == 'Netcore')">
Expand Down Expand Up @@ -353,4 +355,4 @@ $(RepoArtifacts)/$(Configuration)/**/Microsoft.Azure.PowerShell.Authenticators.d
<SetEnvVar EnvName="SignedMsiDir" EnvValue="$(SignedOutputRootDir)" />
</Target>

</Project>
</Project>
58 changes: 58 additions & 0 deletions tools/CompleteOutputTypeIndex.ps1
Original file line number Diff line number Diff line change
@@ -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"
16 changes: 8 additions & 8 deletions tools/NewHelpIndex.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"))}

Expand Down

0 comments on commit 11337fd

Please sign in to comment.