1
1
# To version all modules in Az (standard release), run the following command: .\RunVersionController.ps1 -Release "December 2017"
2
2
# 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
+
3
6
[CmdletBinding (DefaultParameterSetName = " ReleaseAz" )]
4
7
Param (
5
8
[Parameter (ParameterSetName = ' ReleaseAz' , Mandatory = $true )]
@@ -151,16 +154,9 @@ function Update-ChangeLog
151
154
($Content + $ChangeLogContent ) | Set-Content - Path $ChangeLogFile.FullName - Encoding UTF8
152
155
}
153
156
154
- if ( ! ( Test-Path " C:/Program Files/PowerShell/Modules/PowerShellGet " ))
157
+ function Get-ExistSerializedCmdletJsonFile
155
158
{
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
164
160
}
165
161
166
162
switch ($PSCmdlet.ParameterSetName )
@@ -172,6 +168,38 @@ switch ($PSCmdlet.ParameterSetName)
172
168
173
169
" ReleaseAz"
174
170
{
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
+ }
175
203
try
176
204
{
177
205
Install-Module Az - Repository $GalleryName - Force - AllowClobber
0 commit comments