Skip to content

Commit c9aeca5

Browse files
authored
[Eng] Fixed data plane suffix in Linux system (#28138)
1 parent 3a584ca commit c9aeca5

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

tools/BuildScripts/BuildScripts.psm1

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ function Update-GeneratedSubModule {
132132

133133
# save guid from psd1 if existed for later use
134134
$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
137138
}
138139

139140
# clean generated directory before update
@@ -160,22 +161,31 @@ function Update-GeneratedSubModule {
160161
if (Test-Path $localModulesPath) {
161162
Remove-Item -Path $localModulesPath -Recurse -Force
162163
}
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')
164170
# Copy from src/ to generated/
165171
$fileToUpdate | Foreach-Object {
166172
$moveFrom = Join-Path $SourceDirectory $_
167173
$moveTo = Join-Path $GeneratedDirectory $_
168174
Write-Host "Copying $moveFrom to $moveTo ..." -ForegroundColor Cyan
169175
Copy-Item -Path $moveFrom -Destination $moveTo -Recurse -Force
170176
}
177+
$cSubModuleNameTrimmed = $subModuleNameTrimmed
178+
if ($csprojName -match "^Az\.(?<cSubModuleName>\w+)\.csproj$") {
179+
$cSubModuleNameTrimmed = $Matches["cSubModuleName"]
180+
}
171181
# 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
173183

174184
# revert guid in psd1 so that no conflict in updating this file
175185
if ($guid) {
176-
$psd1Path = Join-Path $GeneratedDirectory "Az.$subModuleNameTrimmed.psd1"
186+
$psd1Path = Join-Path $GeneratedDirectory $psd1Name
177187
$psd1Content = Get-Content $psd1Path
178-
$newGuid = (Import-LocalizedData -BaseDirectory $GeneratedDirectory -FileName "Az.$subModuleNameTrimmed.psd1").GUID
188+
$newGuid = (Import-LocalizedData -BaseDirectory $GeneratedDirectory -FileName $psd1Name).GUID
179189
$psd1Content -replace $newGuid, $guid | Set-Content $psd1Path -Force
180190
}
181191

0 commit comments

Comments
 (0)