@@ -127,22 +127,37 @@ $ModuleMapping.Keys | ForEach-Object -Begin { $RequestCount = 0 } -End { Write-H
127127 [HashTable ]$PrivateData = @ { Profiles = $Profiles }
128128 Update-ModuleManifest - Path $ModuleManifestPath - PrivateData $PrivateData
129129
130- # Update module psm1 with Graph session profile name .
130+ # Update main module psm1.
131131 $ModulePsm1 = Join-Path $ModuleProjectDir " /$ModulePrefix .$ModuleName .psm1"
132132 (Get-Content - Path $ModulePsm1 ) | ForEach-Object {
133- $_
134133 if ($_ -match ' \$instance = \[Microsoft.Graph.PowerShell.Module\]::Instance' ) {
134+ # Update main psm1 with Graph session profile name and module name.
135+ $_
135136 ' $instance.ProfileName = [Microsoft.Graph.PowerShell.Authentication.GraphSession]::Instance.SelectedProfile'
137+ } else {
138+ # Rename all Azure instances in psm1 to `Microsoft Graph`.
139+ $updatedLine = $_ -replace ' Azure' , ' Microsoft Graph'
140+ # Replace all 'instance.Name' declarations with fully qualified module name.
141+ $updatedLine = $updatedLine -replace ' \$\(\$instance.Name\)' , " $ModulePrefix .$ModuleName "
142+ $updatedLine
136143 }
137144 } | Set-Content $ModulePsm1
138145
139- # Address AutoREST bug where it looks for exports in the wrong directory .
146+ # Update internal module psm1 .
140147 $InternalModulePsm1 = Join-Path $ModuleProjectDir " /internal/$ModulePrefix .$ModuleName .internal.psm1"
141148 (Get-Content - Path $InternalModulePsm1 ) | ForEach-Object {
142- $_
149+ $updatedLine = $_
150+ # Address AutoREST bug where it looks for exports in the wrong directory.
143151 if ($_ -match ' \$exportsPath = \$PSScriptRoot' ) {
144- ' $exportsPath = Join-Path $PSScriptRoot "../exports"'
152+ $updatedLine = ' $exportsPath = Join-Path $PSScriptRoot "../exports"'
145153 }
154+
155+ # Remove duplicate instance.Name declarations in internal.psm1
156+ # Main .psm1 already handles this.
157+ if ($_ -match ' \$\(\$instance.Name\)' ) {
158+ $updatedLine = " "
159+ }
160+ $updatedLine
146161 } | Set-Content $InternalModulePsm1
147162
148163 if ($LASTEXITCODE ) {
0 commit comments