Skip to content

Commit 729c106

Browse files
azure-powershell-botazurepowershell
andauthored
Sync tools folder from main branch to generation branch (#24240)
Co-authored-by: azurepowershell <[email protected]>
1 parent 028204f commit 729c106

File tree

5 files changed

+109
-77
lines changed

5 files changed

+109
-77
lines changed

.azure-pipelines/code-sign.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ jobs:
5252
custom: msbuild
5353
arguments: 'build.proj /t:"Build;CopyAboutTopics;GenerateHelp" /p:"Configuration=Release;GenerateDocumentationFile=true;ModifiedModuleBuild=true"'
5454

55-
5655
- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
5756
displayName: 'Manifest Generator '
5857
inputs:
@@ -363,6 +362,11 @@ jobs:
363362
displayName: 'Repackage modules'
364363
condition: and(succeeded(), ne(variables['SignPsd1'], 'false'))
365364

365+
- pwsh: |
366+
./tools/Docs/OutputTypeIndex.ps1 -OutputFile ./artifacts/outputtypes.json -BuildConfig Release
367+
./tools/Docs/HelpIndex.ps1 -OutputFile ./artifacts/index.json -BuildConfig Release
368+
displayName: 'Post process for Docs'
369+
366370
- task: PublishBuildArtifacts@1
367371
displayName: 'Save artifacts'
368372
inputs:

build.proj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,6 @@
260260

261261
<Target Name="Publish" Condition="'$(Configuration)' == 'Release'">
262262
<Message Importance="high" Text="Publishing Cmdlets using $(Scope) scope" />
263-
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/NewOutputTypeIndex.ps1 -OutputFile $(RepoArtifacts)/outputtypes.json -BuildConfig $(Configuration)&quot;"/>
264-
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/NewHelpIndex.ps1 -OutputFile $(RepoArtifacts)/index.json -BuildConfig $(Configuration)&quot;"/>
265-
266263
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/CleanupBuild.ps1 -BuildConfig $(Configuration) -GenerateDocumentationFile $(GenerateDocumentationFile) &quot;" />
267264

268265
<Error Condition="'$(NuGetKey)' == ''" Text="You must provide the NuGetKey parameter to the build: /p:NuGetKey=YOUR_PUBLISHING_KEY" />

tools/NewHelpIndex.ps1 renamed to tools/Docs/HelpIndex.ps1

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ param(
2828
[Parameter(Mandatory = $false)]
2929
[string] $BuildConfig = "Debug",
3030
[Parameter(Mandatory = $false)]
31-
[string] $OutputFile = "$PSScriptRoot/index.json"
31+
[string] $OutputFile = "$PSScriptRoot/../index.json"
3232
)
3333

34-
Import-LocalizedData -BindingVariable "Azpsd1" -BaseDirectory $PSScriptRoot/Az -FileName "Az.psd1"
34+
$ToolsRootPath = "$PSScriptRoot/.."
35+
36+
Import-LocalizedData -BindingVariable "Azpsd1" -BaseDirectory $ToolsRootPath/Az -FileName "Az.psd1"
3537

3638
if ([string]::isNullOrEmpty($Version))
3739
{
@@ -60,21 +62,24 @@ $output.Add("version", "$Version")
6062
$outputModules = @{}
6163

6264
#Create mappings file
63-
& "$PSScriptRoot/CreateMappings.ps1" -OutputFile $OutputFile/../groupMapping.json -WarningFile $OutputFile/../groupMappingWarnings.json
65+
& "ToolsRootPath/CreateMappings.ps1" -OutputFile $OutputFile/../groupMapping.json -WarningFile $OutputFile/../groupMappingWarnings.json
6466
$labelMapping = Get-Content -Raw $OutputFile/../groupMapping.json | ConvertFrom-Json
6567

66-
$RMpsd1s = @()
6768
$HelpFolders = @()
6869

69-
$resourceManagerPath = "$PSScriptRoot/../artifacts/$BuildConfig/"
70-
71-
$RMpsd1s += Get-ChildItem -Path $resourceManagerPath -Depth 1 | Where-Object {
72-
$_.Name -like "*.psd1" -and $_.FullName -notlike "*dll-Help*"
70+
$ProjectPaths = @( "ToolsRootPath/../src")
71+
$RMpsd1s = $ProjectPaths | ForEach-Object {
72+
Get-ChildItem -Path $_ -Filter "*.psd1" -Recurse | Where-Object {
73+
$_.FullName -inotlike "*autorest*" -and `
74+
$_.FullName -inotlike "*extension*" -and `
75+
$_.FullName -notlike "*Debug*" -and `
76+
$_.FullName -notlike "*Netcore*" -and `
77+
$_.FullName -notlike "*dll-Help.psd1*" -and (-not [Tools.Common.Utilities.ModuleFilter]::IsAzureStackModule($_.FullName))
78+
}
7379
}
7480

75-
.($PSScriptRoot + "\PreloadToolDll.ps1")
76-
$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"))}
77-
81+
.($ToolsRootPath + "\PreloadToolDll.ps1")
82+
$HelpFolders += Get-ChildItem -Path "$ToolsRootPath/../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"))}
7883

7984
# Map the name of the cmdlet to the location of the help file
8085
$HelpFileMapping = @{}

tools/Docs/OutputTypeIndex.ps1

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
param(
16+
[Parameter(Mandatory = $false)]
17+
[string] $BuildConfig = "Release",
18+
[Parameter(Mandatory = $false)]
19+
[string] $OutputFile = "outputtypes.json"
20+
)
21+
22+
$ToolsRootPath = "$PSScriptRoot/.."
23+
$AzPreviewPath = Get-Item $ToolsRootPath\AzPreview\AzPreview.psd1
24+
Import-LocalizedData -BindingVariable ModuleMetadata -BaseDirectory $AzPreviewPath.DirectoryName -FileName $AzPreviewPath.Name
25+
$ModulePath = ($env:PSModulePath -split ';')[0]
26+
$outputTypes = New-Object System.Collections.Generic.HashSet[string]
27+
$jsonData = @()
28+
$ProjectPaths = @( "$ToolsRootPath/../src" )
29+
30+
$ModuleManifestFile = $ProjectPaths | ForEach-Object {
31+
Get-ChildItem -Path $_ -Filter "*.psd1" -Recurse | Where-Object {
32+
$_.FullName -notlike "*autorest*"
33+
}
34+
}
35+
36+
foreach ($item in $jsonData) {
37+
$outputTypes.Add($item) | Out-Null
38+
}
39+
40+
$ReleaseRepository = "ReleaseRP"
41+
Register-PSRepository -Name $ReleaseRepository -SourceLocation "$ToolsRootPath/../artifacts" -PackageManagementProvider Nuget -InstallationPolicy Trusted
42+
Install-Module -Scope CurrentUser -Name AzPreview -Repository $ReleaseRepository -Force -AllowClobber
43+
44+
$ModuleMetadata.RequiredModules | ForEach-Object {
45+
$ModuleName = $_.ModuleName
46+
$Version = $_.RequiredVersion
47+
if ($Version -eq $null)
48+
{
49+
$Version = $_.ModuleVersion
50+
}
51+
$srcFile = $ModuleManifestFile | Where-Object {$_.Name -eq "$ModuleName.psd1"}
52+
Import-LocalizedData -BindingVariable srcMetadata -BaseDirectory $srcFile.DirectoryName -FileName $srcFile.Name
53+
$containsPsd1 = $srcMetadata.NestedModules | Where-Object { $_ -like "*.dll" }
54+
$DestinationModulePath = [System.IO.Path]::Combine($ModulePath, $ModuleName, $Version)
55+
$psd1Path = Join-Path -Path $DestinationModulePath -ChildPath "$ModuleName.psd1"
56+
if (($containsPsd1.count -gt 0) -and (Test-Path $psd1Path)){
57+
Import-Module $Psd1Path -Force
58+
$Module = Get-Module $ModuleName
59+
foreach ($ModuleInfo in $Module.NestedModules){
60+
if ($srcMetadata.NestedModules -contains $ModuleInfo.Name+".dll") {
61+
foreach ($Cmdlet in $ModuleInfo.ExportedCmdlets.Values) {
62+
$OutputAttributeList = $Cmdlet.ImplementingType.GetTypeInfo().GetCustomAttributes([System.Management.Automation.OutputTypeAttribute], $true)
63+
foreach ($OutputAttribute in $OutputAttributeList)
64+
{
65+
foreach ($OutputType in $OutputAttribute.Type)
66+
{
67+
$outputTypes.Add($OutputType.Name) | Out-Null
68+
}
69+
}
70+
foreach ($Parameter in $Cmdlet.Parameters.Values){
71+
if ($Parameter.Attributes.TypeId.FullName -contains "System.Management.Automation.ParameterAttribute") {
72+
if ($Parameter.ParameterType.FullName -like "*System.Nullable*``[``[*")
73+
{
74+
$outputTypes.Add(($Parameter.ParameterType.BaseType.FullName -replace "[][]", "")) | Out-Null
75+
}
76+
elseif ($Parameter.ParameterType.FullName -notlike "*``[``[*")
77+
{
78+
$outputTypes.Add(($Parameter.ParameterType.FullName -replace "[][]", "")) | Out-Null
79+
}
80+
}
81+
}
82+
}
83+
}
84+
}
85+
}
86+
}
87+
$json = ConvertTo-Json $outputTypes
88+
$json | Out-File "$OutputFile"

tools/NewOutputTypeIndex.ps1

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)