@@ -132,8 +132,9 @@ function Update-GeneratedSubModule {
132
132
133
133
# save guid from psd1 if existed for later use
134
134
$subModuleNameTrimmed = $SubModuleName.split (' .' )[-2 ]
135
- if (Test-Path (Join-Path $GeneratedDirectory " Az.$subModuleNameTrimmed .psd1" )) {
136
- $guid = (Import-LocalizedData - BaseDirectory $GeneratedDirectory - FileName " Az.$subModuleNameTrimmed .psd1" ).GUID
135
+ $psd1Name = Get-ChildItem $GeneratedDirectory | Where-Object { $_.Name -match " Az\.${subModuleNameTrimmed} \.psd1" } | Foreach-Object {$_.Name }
136
+ if ($psd1Name -And (Test-Path (Join-Path $GeneratedDirectory $psd1Name ))) {
137
+ $guid = (Import-LocalizedData - BaseDirectory $GeneratedDirectory - FileName $psd1Name ).GUID
137
138
}
138
139
139
140
# clean generated directory before update
@@ -160,22 +161,31 @@ function Update-GeneratedSubModule {
160
161
if (Test-Path $localModulesPath ) {
161
162
Remove-Item - Path $localModulesPath - Recurse - Force
162
163
}
163
- $fileToUpdate = @ (' generated' , ' resources' , " Az.$subModuleNameTrimmed .psd1" , " Az.$subModuleNameTrimmed .psm1" , " Az.$subModuleNameTrimmed .format.ps1xml" , ' exports' , ' internal' , ' test-module.ps1' , ' check-dependencies.ps1' )
164
+
165
+ $psd1Name = Get-ChildItem $SourceDirectory | Where-Object { $_.Name -match " Az\.${subModuleNameTrimmed} \.psd1" } | Foreach-Object {$_.Name }
166
+ $psm1Name = Get-ChildItem $SourceDirectory | Where-Object { $_.Name -match " Az\.${subModuleNameTrimmed} \.psm1" } | Foreach-Object {$_.Name }
167
+ $formatName = Get-ChildItem $SourceDirectory | Where-Object { $_.Name -match " Az\.${subModuleNameTrimmed} \.format\.ps1xml" } | Foreach-Object {$_.Name }
168
+ $csprojName = Get-ChildItem $SourceDirectory | Where-Object { $_.Name -match " Az\.${subModuleNameTrimmed} \.csproj" } | Foreach-Object {$_.Name }
169
+ $fileToUpdate = @ (' generated' , ' resources' , $psd1Name , $psm1Name , $formatName , ' exports' , ' internal' , ' test-module.ps1' , ' check-dependencies.ps1' )
164
170
# Copy from src/ to generated/
165
171
$fileToUpdate | Foreach-Object {
166
172
$moveFrom = Join-Path $SourceDirectory $_
167
173
$moveTo = Join-Path $GeneratedDirectory $_
168
174
Write-Host " Copying $moveFrom to $moveTo ..." - ForegroundColor Cyan
169
175
Copy-Item - Path $moveFrom - Destination $moveTo - Recurse - Force
170
176
}
177
+ $cSubModuleNameTrimmed = $subModuleNameTrimmed
178
+ if ($csprojName -match " ^Az\.(?<cSubModuleName>\w+)\.csproj$" ) {
179
+ $cSubModuleNameTrimmed = $Matches [" cSubModuleName" ]
180
+ }
171
181
# regenerate csproj
172
- New-GeneratedFileFromTemplate - TemplateName ' Az.ModuleName.csproj' - GeneratedFileName " Az. $subModuleNameTrimmed .csproj " - GeneratedDirectory $GeneratedDirectory - ModuleRootName $ModuleRootName - SubModuleName $subModuleNameTrimmed - SubModuleNameFull $SubModuleName
182
+ New-GeneratedFileFromTemplate - TemplateName ' Az.ModuleName.csproj' - GeneratedFileName $csprojName - GeneratedDirectory $GeneratedDirectory - ModuleRootName $ModuleRootName - SubModuleName $cSubModuleNameTrimmed - SubModuleNameFull $SubModuleName
173
183
174
184
# revert guid in psd1 so that no conflict in updating this file
175
185
if ($guid ) {
176
- $psd1Path = Join-Path $GeneratedDirectory " Az. $subModuleNameTrimmed .psd1 "
186
+ $psd1Path = Join-Path $GeneratedDirectory $psd1Name
177
187
$psd1Content = Get-Content $psd1Path
178
- $newGuid = (Import-LocalizedData - BaseDirectory $GeneratedDirectory - FileName " Az. $subModuleNameTrimmed .psd1 " ).GUID
188
+ $newGuid = (Import-LocalizedData - BaseDirectory $GeneratedDirectory - FileName $psd1Name ).GUID
179
189
$psd1Content -replace $newGuid , $guid | Set-Content $psd1Path - Force
180
190
}
181
191
0 commit comments