1212# limitations under the License.
1313# ----------------------------------------------------------------------------------
1414
15+ # The generated excel will contains one sheet. The title is:
16+ # ModuleName, CmdletName, Description, Before, After, TeamMember, PR
17+
18+ # .\tools\BreakingChanges\GenerateMigrationExcel.ps1 -ExcelPath (Join-Path $env:USERPROFILE "Documents" "2024-05-21-Az-12.0-Breaking-Change-Migration-Guide.xlsx")
19+
1520# Requires -Modules PSExcel
1621[CmdletBinding ()]
1722Param (
1823 [Parameter ()]
1924 [string ]$ExcelPath
2025)
21- $ExcelPath = Resolve-Path - Path $ExcelPath
2226If (Test-Path $ExcelPath ) {
2327 Remove-Item $ExcelPath
2428}
2529$Path = [System.IO.Path ]::Combine($PSScriptRoot , ' ..' , ' ..' )
2630Set-Location - Path $Path
27- Get-ChildItem - Path .\tools\StaticAnalysis\Exceptions\ - Filter BreakingChangeIssues.csv - Recurse
28- dotnet msbuild / t:Clean
29- dotnet msbuild / t:Build
30- dotnet msbuild / t:StaticAnalysis
31- $BreakingChangeItems = Import-Csv .\artifacts\StaticAnalysisResults\BreakingChangeIssues.csv
32- $TotalTable = @ {}
33- foreach ($BreakingChangeItem in $BreakingChangeItems ) {
34- $ModuleName = ' Az' + $BreakingChangeItem.AssemblyFileName.Replace (" Microsoft.Azure.PowerShell.Cmdlets" , " " ).Replace(' .dll' , ' ' )
35- $CmdletName = $BreakingChangeItem.Target
36- $Description = $BreakingChangeItem.Description
37- if (-not $TotalTable.ContainsKey ($ModuleName )) {
38- $TotalTable.Add ($ModuleName , @ {})
39- }
40- if (-not $TotalTable [$ModuleName ].ContainsKey($CmdletName )) {
41- $TotalTable [$ModuleName ].Add($CmdletName , " " )
42- }
43- $TotalTable [$ModuleName ][$CmdletName ] = $TotalTable [$ModuleName ][$CmdletName ] + " $Description `n "
44- }
31+ # dotnet msbuild /t:Clean
32+ # dotnet msbuild /t:Build
33+ # dotnet msbuild /t:StaticAnalysis
4534
35+ Import-Module (Join-Path $PSScriptRoot " Get-BreakingChangeMetadata.ps1" ) - Force
36+ $ArtifactsPath = [System.IO.Path ]::Combine($Path , " artifacts" , " Debug" )
37+
38+ $AllModuleList = Get-ChildItem - Path $ArtifactsPath - Filter Az.* | ForEach-Object { $_.Name }
4639$Data = New-Object System.Collections.ArrayList
47- foreach ($ModuleName in $TotalTable.Keys ) {
48- foreach ($CmdletName in $TotalTable [$ModuleName ].Keys) {
49- $Tmp = New-Object - TypeName PSObject - Property @ {
40+ ForEach ($ModuleName In $AllModuleList )
41+ {
42+ Write-Host " Processing Module: $ModuleName "
43+ $ModuleBreakingChangeInfo = Get-BreakingChangeMetadata - ArtifactsPath $ArtifactsPath - ModuleName $ModuleName
44+ If ($ModuleBreakingChangeInfo.Count -eq 0 )
45+ {
46+ Continue
47+ }
48+
49+ ForEach ($CmdletName In ($ModuleBreakingChangeInfo.Keys | Sort-Object ))
50+ {
51+ Write-Host " Processing Cmdlet: $ModuleName - $CmdletName "
52+ $NewRow = New-Object - TypeName PSObject - Property @ {
5053 ModuleName = $ModuleName
5154 CmdletName = $CmdletName
52- Description = $TotalTable [ $ModuleName ] [$CmdletName ]
55+ Description = Export-BreakingChangeMessageOfCmdlet $ModuleBreakingChangeInfo [$CmdletName ]
5356 Before = $Null
5457 After = $Null
5558 TeamMember = $Null
5659 PR = $Null
57- } | Select ModuleName, CmdletName, Description, Before, After, TeamMember, PR
58- $Null = $Data.Add ($Tmp )
60+ } | Select-Object ModuleName, CmdletName, Description, Before, After, TeamMember, PR
61+ $Null = $Data.Add ($NewRow )
5962 }
6063}
64+
6165$Data | Export-XLSX - Path $ExcelPath
6266Write-Host " Excel is generated at $ExcelPath . Please goto edit it."
0 commit comments