Skip to content

Commit f0af88b

Browse files
rootwyunchi1990
authored andcommitted
1. Fix the bug that can not find the right version PowerShellGet in some system.
2. Make sure will not contain the moudle which's version is lower than 1.0.0. And remove used json files in SerializedCmdlets.
1 parent f7382d9 commit f0af88b

File tree

28 files changed

+37
-180245
lines changed

28 files changed

+37
-180245
lines changed

tools/RunVersionController.ps1

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# To version all modules in Az (standard release), run the following command: .\RunVersionController.ps1 -Release "December 2017"
22
# To version a single module (one-off release), run the following command: .\RunVersionController.ps1 -ModuleName "Az.Compute"
3+
4+
#Requires -Modules @{ModuleName="PowerShellGet"; ModuleVersion="2.2.1"}
5+
36
[CmdletBinding(DefaultParameterSetName="ReleaseAz")]
47
Param(
58
[Parameter(ParameterSetName='ReleaseAz', Mandatory = $true)]
@@ -151,16 +154,9 @@ function Update-ChangeLog
151154
($Content + $ChangeLogContent) | Set-Content -Path $ChangeLogFile.FullName -Encoding UTF8
152155
}
153156

154-
if (!(Test-Path "C:/Program Files/PowerShell/Modules/PowerShellGet"))
157+
function Get-ExistSerializedCmdletJsonFile
155158
{
156-
try
157-
{
158-
Save-Module -Name PowerShellGet -Repository $GalleryName -Path "C:/Program Files/PowerShell/Modules" -ErrorAction Stop
159-
}
160-
catch
161-
{
162-
throw "Please rerun in Administrator mode."
163-
}
159+
return $(ls "$PSScriptRoot\Tools.Common\SerializedCmdlets").Name
164160
}
165161

166162
switch ($PSCmdlet.ParameterSetName)
@@ -172,6 +168,38 @@ switch ($PSCmdlet.ParameterSetName)
172168

173169
"ReleaseAz"
174170
{
171+
172+
# clean the unnecessary SerializedCmdlets json file
173+
$ExistSerializedCmdletJsonFile = Get-ExistSerializedCmdletJsonFile
174+
$ExpectJsonHashSet = @{}
175+
$SrcPath = "..\src"
176+
foreach ($ModuleName in $(Get-ChildItem $SrcPath -Directory).Name)
177+
{
178+
$ModulePath = $(Join-Path -Path $SrcPath -ChildPath $ModuleName)
179+
$Psd1FileName = "Az.{0}.psd1" -f $ModuleName
180+
$Psd1FilePath = $(Get-ChildItem $ModulePath -Depth 2 -Recurse -Filter $Psd1FileName)
181+
if ($null -ne $Psd1FilePath)
182+
{
183+
$Psd1Object = Import-PowerShellDataFile $Psd1FilePath
184+
if ($Psd1Object.ModuleVersion -ge "1.0.0")
185+
{
186+
foreach ($NestedModule in $Psd1Object.NestedModules)
187+
{
188+
$JsonFile = $NestedModule.Replace(".\", "") + ".json"
189+
$ExpectJsonHashSet.Add($JsonFile, $true)
190+
}
191+
}
192+
}
193+
}
194+
foreach ($JsonFile in $ExistSerializedCmdletJsonFile)
195+
{
196+
$ModuleName = $JsonFile.Replace('Microsoft.Azure.PowerShell.Cmdlets.', '').Replace('.dll.json', '')
197+
if (!$ExpectJsonHashSet.Contains($JsonFile))
198+
{
199+
Write-Host "Module ${ModuleName} is not GA yet. Remove the json file: ${JsonFile}." -ForegroundColor Red
200+
rm $(Join-Path -Path "$PSScriptRoot\Tools.Common\SerializedCmdlets" -ChildPath $JsonFile)
201+
}
202+
}
175203
try
176204
{
177205
Install-Module Az -Repository $GalleryName -Force -AllowClobber

0 commit comments

Comments
 (0)